1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-24 23:57:30 +00:00
This commit is contained in:
Austin Huang 2020-08-06 22:26:23 -04:00
parent 45bf250657
commit d48bc32a15
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
15 changed files with 238 additions and 219 deletions

View File

@ -9,8 +9,8 @@ android {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 29 targetSdkVersion 29
versionCode 40 versionCode 41
versionName '17.4' versionName '17.5'
multiDexEnabled true multiDexEnabled true

View File

@ -240,7 +240,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
if (tag instanceof FeedStoryModel) { if (tag instanceof FeedStoryModel) {
final FeedStoryModel feedStoryModel = (FeedStoryModel) tag; final FeedStoryModel feedStoryModel = (FeedStoryModel) tag;
final int index = indexOfIntArray(stories, feedStoryModel); final int index = indexOfIntArray(stories, feedStoryModel);
new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, result -> { new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, false, false, result -> {
if (result != null && result.length > 0) if (result != null && result.length > 0)
main.startActivity(new Intent(main, StoryViewer.class) main.startActivity(new Intent(main, StoryViewer.class)
.putExtra(Constants.EXTRAS_STORIES, result) .putExtra(Constants.EXTRAS_STORIES, result)
@ -733,31 +733,31 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
main.mainBinding.btnFollowTag.setVisibility(View.VISIBLE); main.mainBinding.btnFollowTag.setVisibility(View.VISIBLE);
if (isLoggedIn) { if (isLoggedIn) {
new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, result -> { new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, false, result -> {
main.storyModels = result; main.storyModels = result;
if (result != null && result.length > 0) main.mainBinding.mainHashtagImage.setStoriesBorder(); if (result != null && result.length > 0) main.mainBinding.mainHashtagImage.setStoriesBorder();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (hashtagModel.getFollowing() == true) { if (hashtagModel.getFollowing() == true) {
main.mainBinding.btnFollowTag.setText(R.string.unfollow); main.mainBinding.btnFollowTag.setText(R.string.unfollow);
main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_purple_background, null))); main, R.color.btn_purple_background)));
} }
else { else {
main.mainBinding.btnFollowTag.setText(R.string.follow); main.mainBinding.btnFollowTag.setText(R.string.follow);
main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_pink_background, null))); main, R.color.btn_pink_background)));
} }
} else { } else {
if (Utils.dataBox.getFavorite(main.userQuery) != null) { if (Utils.dataBox.getFavorite(main.userQuery) != null) {
main.mainBinding.btnFollowTag.setText(R.string.unfavorite_short); main.mainBinding.btnFollowTag.setText(R.string.unfavorite_short);
main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_purple_background, null))); main, R.color.btn_purple_background)));
} }
else { else {
main.mainBinding.btnFollowTag.setText(R.string.favorite_short); main.mainBinding.btnFollowTag.setText(R.string.favorite_short);
main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollowTag.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_pink_background, null))); main, R.color.btn_pink_background)));
} }
} }
@ -795,20 +795,22 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
final String cookie = Utils.settingsHelper.getString(Constants.COOKIE); final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
final boolean isLoggedIn = !Utils.isEmpty(cookie); final boolean isLoggedIn = !Utils.isEmpty(cookie);
new iStoryStatusFetcher(profileId, profileModel.getUsername(), false, false,
(!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), false,
result -> {
main.storyModels = result;
if (result != null && result.length > 0) main.mainBinding.mainProfileImage.setStoriesBorder();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new HighlightsFetcher(profileId, (!isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), result -> {
if (result != null && result.length > 0) {
main.mainBinding.highlightsList.setVisibility(View.VISIBLE);
main.highlightsAdapter.setData(result);
}
else main.mainBinding.highlightsList.setVisibility(View.GONE);
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if (isLoggedIn) { if (isLoggedIn) {
new iStoryStatusFetcher(profileId, profileModel.getUsername(), false, false, result -> {
main.storyModels = result;
if (result != null && result.length > 0) main.mainBinding.mainProfileImage.setStoriesBorder();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new HighlightsFetcher(profileId, result -> {
if (result != null && result.length > 0) {
main.mainBinding.highlightsList.setVisibility(View.VISIBLE);
main.highlightsAdapter.setData(result);
}
else main.mainBinding.highlightsList.setVisibility(View.GONE);
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
final String myId = Utils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE)); final String myId = Utils.getUserIdFromCookie(Utils.settingsHelper.getString(Constants.COOKIE));
if (!profileId.equals(myId)) { if (!profileId.equals(myId)) {
main.mainBinding.btnTagged.setVisibility(View.GONE); main.mainBinding.btnTagged.setVisibility(View.GONE);
@ -817,41 +819,41 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
main.mainBinding.btnFollow.setVisibility(View.VISIBLE); main.mainBinding.btnFollow.setVisibility(View.VISIBLE);
if (profileModel.getFollowing() == true) { if (profileModel.getFollowing() == true) {
main.mainBinding.btnFollow.setText(R.string.unfollow); main.mainBinding.btnFollow.setText(R.string.unfollow);
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_purple_background, null))); main, R.color.btn_purple_background)));
} }
else if (profileModel.getRequested() == true) { else if (profileModel.getRequested() == true) {
main.mainBinding.btnFollow.setText(R.string.cancel); main.mainBinding.btnFollow.setText(R.string.cancel);
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_purple_background, null))); main, R.color.btn_purple_background)));
} }
else { else {
main.mainBinding.btnFollow.setText(R.string.follow); main.mainBinding.btnFollow.setText(R.string.follow);
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_pink_background, null))); main, R.color.btn_pink_background)));
} }
main.mainBinding.btnRestrict.setVisibility(View.VISIBLE); main.mainBinding.btnRestrict.setVisibility(View.VISIBLE);
if (profileModel.getRestricted() == true) { if (profileModel.getRestricted() == true) {
main.mainBinding.btnRestrict.setText(R.string.unrestrict); main.mainBinding.btnRestrict.setText(R.string.unrestrict);
main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_green_background, null))); main, R.color.btn_green_background)));
} }
else { else {
main.mainBinding.btnRestrict.setText(R.string.restrict); main.mainBinding.btnRestrict.setText(R.string.restrict);
main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_orange_background, null))); main, R.color.btn_orange_background)));
} }
if (profileModel.isReallyPrivate()) { if (profileModel.isReallyPrivate()) {
main.mainBinding.btnBlock.setVisibility(View.VISIBLE); main.mainBinding.btnBlock.setVisibility(View.VISIBLE);
main.mainBinding.btnTagged.setVisibility(View.GONE); main.mainBinding.btnTagged.setVisibility(View.GONE);
if (profileModel.getBlocked() == true) { if (profileModel.getBlocked() == true) {
main.mainBinding.btnBlock.setText(R.string.unblock); main.mainBinding.btnBlock.setText(R.string.unblock);
main.mainBinding.btnBlock.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnBlock.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_green_background, null))); main, R.color.btn_green_background)));
} else { } else {
main.mainBinding.btnBlock.setText(R.string.block); main.mainBinding.btnBlock.setText(R.string.block);
main.mainBinding.btnBlock.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnBlock.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_red_background, null))); main, R.color.btn_red_background)));
} }
} else { } else {
main.mainBinding.btnBlock.setVisibility(View.GONE); main.mainBinding.btnBlock.setVisibility(View.GONE);
@ -859,12 +861,12 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
main.mainBinding.btnTagged.setVisibility(View.VISIBLE); main.mainBinding.btnTagged.setVisibility(View.VISIBLE);
if (profileModel.getBlocked() == true) { if (profileModel.getBlocked() == true) {
main.mainBinding.btnSaved.setText(R.string.unblock); main.mainBinding.btnSaved.setText(R.string.unblock);
main.mainBinding.btnSaved.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_green_background, null))); main, R.color.btn_green_background)));
} else { } else {
main.mainBinding.btnSaved.setText(R.string.block); main.mainBinding.btnSaved.setText(R.string.block);
main.mainBinding.btnSaved.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_red_background, null))); main, R.color.btn_red_background)));
} }
} }
} }
@ -873,26 +875,26 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
main.mainBinding.btnSaved.setVisibility(View.VISIBLE); main.mainBinding.btnSaved.setVisibility(View.VISIBLE);
main.mainBinding.btnLiked.setVisibility(View.VISIBLE); main.mainBinding.btnLiked.setVisibility(View.VISIBLE);
main.mainBinding.btnSaved.setText(R.string.saved); main.mainBinding.btnSaved.setText(R.string.saved);
main.mainBinding.btnSaved.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnSaved.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_orange_background, null))); main, R.color.btn_orange_background)));
} }
} else { } else {
if (Utils.dataBox.getFavorite(main.userQuery) != null) { if (Utils.dataBox.getFavorite(main.userQuery) != null) {
main.mainBinding.btnFollow.setText(R.string.unfavorite_short); main.mainBinding.btnFollow.setText(R.string.unfavorite_short);
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_purple_background, null))); main, R.color.btn_purple_background)));
} }
else { else {
main.mainBinding.btnFollow.setText(R.string.favorite_short); main.mainBinding.btnFollow.setText(R.string.favorite_short);
main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnFollow.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_pink_background, null))); main, R.color.btn_pink_background)));
} }
main.mainBinding.btnFollow.setVisibility(View.VISIBLE); main.mainBinding.btnFollow.setVisibility(View.VISIBLE);
if (!profileModel.isReallyPrivate()) { if (!profileModel.isReallyPrivate()) {
main.mainBinding.btnRestrict.setVisibility(View.VISIBLE); main.mainBinding.btnRestrict.setVisibility(View.VISIBLE);
main.mainBinding.btnRestrict.setText(R.string.tagged); main.mainBinding.btnRestrict.setText(R.string.tagged);
main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( main.mainBinding.btnRestrict.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(
R.color.btn_blue_background, null))); main, R.color.btn_blue_background)));
} }
} }
@ -1010,7 +1012,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
final String cookie = Utils.settingsHelper.getString(Constants.COOKIE); final String cookie = Utils.settingsHelper.getString(Constants.COOKIE);
final boolean isLoggedIn = !Utils.isEmpty(cookie); final boolean isLoggedIn = !Utils.isEmpty(cookie);
if (isLoggedIn) { if (isLoggedIn) {
new iStoryStatusFetcher(profileId.split("/")[0], null, true, false, result -> { new iStoryStatusFetcher(profileId.split("/")[0], null, true, false, false, false, result -> {
main.storyModels = result; main.storyModels = result;
if (result != null && result.length > 0) main.mainBinding.mainLocationImage.setStoriesBorder(); if (result != null && result.length > 0) main.mainBinding.mainLocationImage.setStoriesBorder();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

View File

@ -15,6 +15,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -33,6 +34,7 @@ import awais.instagrabber.adapters.HighlightsAdapter;
import awais.instagrabber.adapters.SuggestionsAdapter; import awais.instagrabber.adapters.SuggestionsAdapter;
import awais.instagrabber.asyncs.SuggestionsFetcher; import awais.instagrabber.asyncs.SuggestionsFetcher;
import awais.instagrabber.asyncs.UsernameFetcher; import awais.instagrabber.asyncs.UsernameFetcher;
import awais.instagrabber.asyncs.i.iStoryStatusFetcher;
import awais.instagrabber.customviews.MouseDrawer; import awais.instagrabber.customviews.MouseDrawer;
import awais.instagrabber.databinding.ActivityMainBinding; import awais.instagrabber.databinding.ActivityMainBinding;
import awais.instagrabber.dialogs.AboutDialog; import awais.instagrabber.dialogs.AboutDialog;
@ -76,10 +78,16 @@ public final class Main extends BaseLanguageActivity {
final Object tag = v.getTag(); final Object tag = v.getTag();
if (tag instanceof HighlightModel) { if (tag instanceof HighlightModel) {
final HighlightModel highlightModel = (HighlightModel) tag; final HighlightModel highlightModel = (HighlightModel) tag;
startActivity(new Intent(Main.this, StoryViewer.class) new iStoryStatusFetcher(highlightModel.getId(), null, false, false,
.putExtra(Constants.EXTRAS_USERNAME, userQuery) (!mainHelper.isLoggedIn && Utils.settingsHelper.getBoolean(Constants.STORIESIG)), true, result -> {
.putExtra(Constants.EXTRAS_HIGHLIGHT, highlightModel.getTitle()) if (result != null && result.length > 0)
.putExtra(Constants.EXTRAS_STORIES, highlightModel.getStoryModels())); startActivity(new Intent(Main.this, StoryViewer.class)
.putExtra(Constants.EXTRAS_USERNAME, userQuery)
.putExtra(Constants.EXTRAS_HIGHLIGHT, highlightModel.getTitle())
.putExtra(Constants.EXTRAS_STORIES, result)
);
else Toast.makeText(Main.this, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
} }
}); });
@ -349,7 +357,7 @@ public final class Main extends BaseLanguageActivity {
public boolean onMenuItemActionCollapse(MenuItem item) { public boolean onMenuItemActionCollapse(MenuItem item) {
menu.findItem(R.id.action_about).setVisible(true); menu.findItem(R.id.action_about).setVisible(true);
menu.findItem(R.id.action_settings).setVisible(true); menu.findItem(R.id.action_settings).setVisible(true);
menu.findItem(R.id.action_dms).setVisible(true); menu.findItem(R.id.action_dms).setVisible(!Utils.isEmpty(Utils.settingsHelper.getString(Constants.COOKIE)));
menu.findItem(R.id.action_quickaccess).setVisible(true); menu.findItem(R.id.action_quickaccess).setVisible(true);
menu.findItem(R.id.action_notif).setVisible(true); menu.findItem(R.id.action_notif).setVisible(true);
return true; return true;

View File

@ -104,6 +104,7 @@ public final class StoryViewer extends BaseLanguageActivity {
private StoryModel currentStory; private StoryModel currentStory;
private String url, username; private String url, username;
private int slidePos = 0, lastSlidePos = 0; private int slidePos = 0, lastSlidePos = 0;
private final String cookie = settingsHelper.getString(Constants.COOKIE);
@Override @Override
protected void onCreate(@Nullable final Bundle savedInstanceState) { protected void onCreate(@Nullable final Bundle savedInstanceState) {
@ -160,7 +161,7 @@ public final class StoryViewer extends BaseLanguageActivity {
Toast.makeText(getApplicationContext(), R.string.be_patient, Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), R.string.be_patient, Toast.LENGTH_SHORT).show();
} else { } else {
fetching = true; fetching = true;
new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, result -> { new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, false, false, result -> {
if (result != null && result.length > 0) { if (result != null && result.length > 0) {
final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class) final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class)
.putExtra(Constants.EXTRAS_STORIES, result) .putExtra(Constants.EXTRAS_STORIES, result)
@ -251,7 +252,7 @@ public final class StoryViewer extends BaseLanguageActivity {
poll.getLeftChoice() + " (" + poll.getLeftCount() + ")", poll.getLeftChoice() + " (" + poll.getLeftCount() + ")",
poll.getRightChoice() + " (" + poll.getRightCount() + ")" poll.getRightChoice() + " (" + poll.getRightCount() + ")"
}), (d, w) -> { }), (d, w) -> {
new VoteAction().execute(w); if (!Utils.isEmpty(cookie)) new VoteAction().execute(w);
}) })
.setPositiveButton(R.string.cancel, null) .setPositiveButton(R.string.cancel, null)
.show(); .show();
@ -285,7 +286,7 @@ public final class StoryViewer extends BaseLanguageActivity {
} }
new AlertDialog.Builder(this).setTitle(quiz.getMyChoice() > -1 ? getString(R.string.story_quizzed) : quiz.getQuestion()) new AlertDialog.Builder(this).setTitle(quiz.getMyChoice() > -1 ? getString(R.string.story_quizzed) : quiz.getQuestion())
.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, choices), (d,w) -> { .setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, choices), (d,w) -> {
if (quiz.getMyChoice() == -1) new QuizAction().execute(w); if (quiz.getMyChoice() == -1 && !Utils.isEmpty(cookie)) new QuizAction().execute(w);
}) })
.setPositiveButton(R.string.cancel, null) .setPositiveButton(R.string.cancel, null)
.show(); .show();
@ -320,14 +321,14 @@ public final class StoryViewer extends BaseLanguageActivity {
@Override @Override
public void onLoadCompleted(final int windowIndex, @Nullable final MediaSource.MediaPeriodId mediaPeriodId, final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData) { public void onLoadCompleted(final int windowIndex, @Nullable final MediaSource.MediaPeriodId mediaPeriodId, final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData) {
if (menuDownload != null) menuDownload.setVisible(true); if (menuDownload != null) menuDownload.setVisible(true);
if (currentStory.canReply() && menuDm != null) menuDm.setVisible(true); if (currentStory.canReply() && menuDm != null && !Utils.isEmpty(cookie)) menuDm.setVisible(true);
storyViewerBinding.progressView.setVisibility(View.GONE); storyViewerBinding.progressView.setVisibility(View.GONE);
} }
@Override @Override
public void onLoadStarted(final int windowIndex, @Nullable final MediaSource.MediaPeriodId mediaPeriodId, final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData) { public void onLoadStarted(final int windowIndex, @Nullable final MediaSource.MediaPeriodId mediaPeriodId, final LoadEventInfo loadEventInfo, final MediaLoadData mediaLoadData) {
if (menuDownload != null) menuDownload.setVisible(true); if (menuDownload != null) menuDownload.setVisible(true);
if (currentStory.canReply() && menuDm != null) menuDm.setVisible(true); if (currentStory.canReply() && menuDm != null && !Utils.isEmpty(cookie)) menuDm.setVisible(true);
storyViewerBinding.progressView.setVisibility(View.VISIBLE); storyViewerBinding.progressView.setVisibility(View.VISIBLE);
} }
@ -373,7 +374,7 @@ public final class StoryViewer extends BaseLanguageActivity {
@Override @Override
public boolean onResourceReady(final Drawable resource, final Object model, final Target<Drawable> target, final DataSource dataSource, final boolean isFirstResource) { public boolean onResourceReady(final Drawable resource, final Object model, final Target<Drawable> target, final DataSource dataSource, final boolean isFirstResource) {
if (menuDownload != null) menuDownload.setVisible(true); if (menuDownload != null) menuDownload.setVisible(true);
if (currentStory.canReply() && menuDm != null) menuDm.setVisible(true); if (currentStory.canReply() && menuDm != null && !Utils.isEmpty(cookie)) menuDm.setVisible(true);
storyViewerBinding.progressView.setVisibility(View.GONE); storyViewerBinding.progressView.setVisibility(View.GONE);
return false; return false;
} }
@ -497,7 +498,7 @@ public final class StoryViewer extends BaseLanguageActivity {
storyViewerBinding.poll.setTag(poll); storyViewerBinding.poll.setTag(poll);
question = currentStory.getQuestion(); question = currentStory.getQuestion();
storyViewerBinding.answer.setVisibility(question != null ? View.VISIBLE : View.GONE); storyViewerBinding.answer.setVisibility((question != null && !Utils.isEmpty(cookie)) ? View.VISIBLE : View.GONE);
storyViewerBinding.answer.setTag(question); storyViewerBinding.answer.setTag(question);
mentions = currentStory.getMentions(); mentions = currentStory.getMentions();
@ -508,8 +509,6 @@ public final class StoryViewer extends BaseLanguageActivity {
storyViewerBinding.quiz.setVisibility(quiz != null ? View.VISIBLE : View.GONE); storyViewerBinding.quiz.setVisibility(quiz != null ? View.VISIBLE : View.GONE);
storyViewerBinding.quiz.setTag(quiz); storyViewerBinding.quiz.setTag(quiz);
storyViewerBinding.toolbar.toolbar.setSubtitle(Utils.datetimeParser.format(new Date(currentStory.getTimestamp() * 1000L)));
releasePlayer(); releasePlayer();
final Intent intent = getIntent(); final Intent intent = getIntent();
if (intent.getBooleanExtra(Constants.EXTRAS_HASHTAG, false)) { if (intent.getBooleanExtra(Constants.EXTRAS_HASHTAG, false)) {
@ -521,6 +520,9 @@ public final class StoryViewer extends BaseLanguageActivity {
if (itemType == MediaItemType.MEDIA_TYPE_VIDEO) setupVideo(); if (itemType == MediaItemType.MEDIA_TYPE_VIDEO) setupVideo();
else setupImage(); else setupImage();
if (!intent.hasExtra(Constants.EXTRAS_HIGHLIGHT))
storyViewerBinding.toolbar.toolbar.setSubtitle(Utils.datetimeParser.format(new Date(currentStory.getTimestamp() * 1000L)));
if (settingsHelper.getBoolean(MARK_AS_SEEN)) new SeenAction().execute(); if (settingsHelper.getBoolean(MARK_AS_SEEN)) new SeenAction().execute();
} }
@ -565,8 +567,7 @@ public final class StoryViewer extends BaseLanguageActivity {
urlConnection.setRequestMethod("POST"); urlConnection.setRequestMethod("POST");
urlConnection.setUseCaches(false); urlConnection.setUseCaches(false);
urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT); urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT);
urlConnection.setRequestProperty("x-csrftoken", urlConnection.setRequestProperty("x-csrftoken", cookie.split("csrftoken=")[1].split(";")[0]);
settingsHelper.getString(Constants.COOKIE).split("csrftoken=")[1].split(";")[0]);
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty("Content-Length", "6"); urlConnection.setRequestProperty("Content-Length", "6");
urlConnection.setDoOutput(true); urlConnection.setDoOutput(true);
@ -601,8 +602,7 @@ public final class StoryViewer extends BaseLanguageActivity {
protected Void doInBackground(Integer... rawchoice) { protected Void doInBackground(Integer... rawchoice) {
int choice = rawchoice[0]; int choice = rawchoice[0];
final String cookie = settingsHelper.getString(Constants.COOKIE); final String url = "https://i.instagram.com/api/v1/media/"+currentStory.getStoryMediaId().split("_")[0]+"/"+quiz.getId()+"/story_quiz_answer/";
final String url = "https://i.instagram.com/api/v1/media/"+currentStory.getStoryMediaId().split("_")[0]+"/"+quiz.getId()+"/story_quiz_answer/";
try { try {
JSONObject ogbody = new JSONObject("{\"client_context\":\"" + UUID.randomUUID().toString() JSONObject ogbody = new JSONObject("{\"client_context\":\"" + UUID.randomUUID().toString()
+"\",\"mutation_token\":\"" + UUID.randomUUID().toString() +"\",\"mutation_token\":\"" + UUID.randomUUID().toString()
@ -650,7 +650,6 @@ public final class StoryViewer extends BaseLanguageActivity {
String action; String action;
protected Void doInBackground(String... rawchoice) { protected Void doInBackground(String... rawchoice) {
final String cookie = settingsHelper.getString(Constants.COOKIE);
final String url = "https://i.instagram.com/api/v1/media/" final String url = "https://i.instagram.com/api/v1/media/"
+currentStory.getStoryMediaId().split("_")[0]+"/"+question.getId()+"/story_question_response/"; +currentStory.getStoryMediaId().split("_")[0]+"/"+question.getId()+"/story_question_response/";
try { try {
@ -696,8 +695,7 @@ public final class StoryViewer extends BaseLanguageActivity {
class SeenAction extends AsyncTask<Void, Void, Void> { class SeenAction extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void... lmao) { protected Void doInBackground(Void... lmao) {
final String cookie = settingsHelper.getString(Constants.COOKIE); final String url = "https://www.instagram.com/stories/reel/seen";
final String url = "https://www.instagram.com/stories/reel/seen";
try { try {
String urlParameters = "reelMediaId="+currentStory.getStoryMediaId().split("_")[0] String urlParameters = "reelMediaId="+currentStory.getStoryMediaId().split("_")[0]
+"&reelMediaOwnerId="+currentStory.getUserId() +"&reelMediaOwnerId="+currentStory.getUserId()
@ -707,8 +705,7 @@ public final class StoryViewer extends BaseLanguageActivity {
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
urlConnection.setRequestMethod("POST"); urlConnection.setRequestMethod("POST");
urlConnection.setUseCaches(false); urlConnection.setUseCaches(false);
urlConnection.setRequestProperty("x-csrftoken", urlConnection.setRequestProperty("x-csrftoken", cookie.split("csrftoken=")[1].split(";")[0]);
settingsHelper.getString(Constants.COOKIE).split("csrftoken=")[1].split(";")[0]);
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length)); urlConnection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length));
urlConnection.setDoOutput(true); urlConnection.setDoOutput(true);
@ -731,8 +728,7 @@ public final class StoryViewer extends BaseLanguageActivity {
protected Void doInBackground(String... rawAction) { protected Void doInBackground(String... rawAction) {
final String action = rawAction[0]; final String action = rawAction[0];
final String url = "https://i.instagram.com/api/v1/direct_v2/create_group_thread/"; final String url = "https://i.instagram.com/api/v1/direct_v2/create_group_thread/";
final String cookie = settingsHelper.getString(Constants.COOKIE); try {
try {
final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
urlConnection.setRequestMethod("POST"); urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("User-Agent", Constants.I_USER_AGENT); urlConnection.setRequestProperty("User-Agent", Constants.I_USER_AGENT);
@ -780,7 +776,6 @@ public final class StoryViewer extends BaseLanguageActivity {
wr2.flush(); wr2.flush();
wr2.close(); wr2.close();
urlConnection2.connect(); urlConnection2.connect();
Log.d("austin_debug", urlConnection2.getResponseCode() + " " + urlParameters2 + " " + cookie);
if (urlConnection2.getResponseCode() == HttpURLConnection.HTTP_OK) { if (urlConnection2.getResponseCode() == HttpURLConnection.HTTP_OK) {
ok = true; ok = true;
} }

View File

@ -17,58 +17,43 @@ import awais.instagrabber.utils.Utils;
public final class HighlightsFetcher extends AsyncTask<Void, Void, HighlightModel[]> { public final class HighlightsFetcher extends AsyncTask<Void, Void, HighlightModel[]> {
private final String id; private final String id;
private final boolean storiesig;
private final FetchListener<HighlightModel[]> fetchListener; private final FetchListener<HighlightModel[]> fetchListener;
public HighlightsFetcher(final String id, final FetchListener<HighlightModel[]> fetchListener) { public HighlightsFetcher(final String id, final boolean storiesig, final FetchListener<HighlightModel[]> fetchListener) {
this.id = id; this.id = id;
this.storiesig = storiesig;
this.fetchListener = fetchListener; this.fetchListener = fetchListener;
} }
@Override @Override
protected HighlightModel[] doInBackground(final Void... voids) { protected HighlightModel[] doInBackground(final Void... voids) {
HighlightModel[] result = null; HighlightModel[] result = null;
String url = "https://www.instagram.com/graphql/query/?query_hash=7c16654f22c819fb63d1183034a5162f&variables=" + String url = "https://" + (storiesig ? "storiesig" : "i.instagram") + ".com/api/v1/highlights/" + id + "/highlights_tray/";
"{\"user_id\":\"" + id + "\",\"include_chaining\":false,\"include_reel\":true,\"include_suggested_users\":false," +
"\"include_logged_out_extras\":false,\"include_highlight_reels\":true}";
try { try {
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setInstanceFollowRedirects(false); conn.setInstanceFollowRedirects(false);
conn.setUseCaches(false); conn.setUseCaches(false);
conn.setRequestProperty("User-Agent", storiesig ? Constants.A_USER_AGENT : Constants.I_USER_AGENT);
conn.connect(); conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
final JSONArray highlightsReel = new JSONObject(Utils.readFromConnection(conn)).getJSONObject("data") final JSONArray highlightsReel = new JSONObject(Utils.readFromConnection(conn)).getJSONArray("tray");
.getJSONObject(Constants.EXTRAS_USER).getJSONObject("edge_highlight_reels").getJSONArray("edges");
final int length = highlightsReel.length(); final int length = highlightsReel.length();
final HighlightModel[] highlightModels = new HighlightModel[length]; final HighlightModel[] highlightModels = new HighlightModel[length];
final String[] highlightIds = new String[length]; final String[] highlightIds = new String[length];
for (int i = 0; i < length; ++i) { for (int i = 0; i < length; ++i) {
final JSONObject highlightNode = highlightsReel.getJSONObject(i).getJSONObject("node"); final JSONObject highlightNode = highlightsReel.getJSONObject(i);
final String id = highlightNode.getString(Constants.EXTRAS_ID);
highlightIds[i] = id;
highlightModels[i] = new HighlightModel( highlightModels[i] = new HighlightModel(
highlightNode.getString("title"), highlightNode.getString("title"),
highlightNode.getJSONObject("cover_media").getString("thumbnail_src") highlightNode.getString(Constants.EXTRAS_ID),
highlightNode.getJSONObject("cover_media").getJSONObject("cropped_image_version").getString("url")
); );
} }
conn.disconnect(); conn.disconnect();
// a22a50ce4582220909e302d6eb84d259
// 45246d3fe16ccc6577e0bd297a5db1ab
url = "https://www.instagram.com/graphql/query/?query_hash=a22a50ce4582220909e302d6eb84d259&variables=" +
"{\"highlight_reel_ids\":" + Utils.highlightIdsMerger(highlightIds) + ",\"reel_ids\":[],\"location_ids\":[],\"precomposed_overlay\":false}";
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setInstanceFollowRedirects(false);
conn.setUseCaches(false);
conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
Utils.putHighlightModels(conn, highlightModels);
}
result = highlightModels; result = highlightModels;
} }

View File

@ -55,11 +55,12 @@ public final class ProfilePictureFetcher extends AsyncTask<Void, Void, String> {
out = data.getJSONObject("hd_profile_pic_url_info").optString("url"); out = data.getJSONObject("hd_profile_pic_url_info").optString("url");
} }
if (Utils.isEmpty(out)) { if (Utils.isEmpty(out) && Utils.settingsHelper.getBoolean(Constants.INSTADP)) {
final HttpURLConnection backup = final HttpURLConnection backup =
(HttpURLConnection) new URL("https://instadp.com/fullsize/" + userName).openConnection(); (HttpURLConnection) new URL("https://instadp.com/fullsize/" + userName).openConnection();
backup.setUseCaches(false); backup.setUseCaches(false);
backup.setRequestMethod("GET"); backup.setRequestMethod("GET");
backup.setRequestProperty("User-Agent", Constants.A_USER_AGENT);
final String instadp = backup.getResponseCode() == HttpURLConnection.HTTP_OK ? Utils.readFromConnection(backup) : null; final String instadp = backup.getResponseCode() == HttpURLConnection.HTTP_OK ? Utils.readFromConnection(backup) : null;
backup.disconnect(); backup.disconnect();
@ -85,7 +86,6 @@ public final class ProfilePictureFetcher extends AsyncTask<Void, Void, String> {
} }
} }
} }
if (out == null) out = picUrl;
} }
} catch (final Exception e) { } catch (final Exception e) {
if (logCollector != null) if (logCollector != null)

View File

@ -23,37 +23,46 @@ import awaisomereport.LogCollector;
import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.logCollector;
public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[]> { public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[]> {
private final String id, username; private final String id;
private final boolean isLoc, isHashtag; private String username;
private final boolean isLoc, isHashtag, storiesig, highlight;
private final FetchListener<StoryModel[]> fetchListener; private final FetchListener<StoryModel[]> fetchListener;
public iStoryStatusFetcher(final String id, final String username, final boolean isLoc, public iStoryStatusFetcher(final String id, final String username, final boolean isLoc,
final boolean isHashtag, final FetchListener<StoryModel[]> fetchListener) { final boolean isHashtag, final boolean storiesig, final boolean highlight,
final FetchListener<StoryModel[]> fetchListener) {
this.id = id; this.id = id;
this.username = username; this.username = username;
this.isLoc = isLoc; this.isLoc = isLoc;
this.isHashtag = isHashtag; this.isHashtag = isHashtag;
this.storiesig = storiesig;
this.highlight = highlight;
this.fetchListener = fetchListener; this.fetchListener = fetchListener;
} }
@Override @Override
protected StoryModel[] doInBackground(final Void... voids) { protected StoryModel[] doInBackground(final Void... voids) {
StoryModel[] result = null; StoryModel[] result = null;
final String url = "https://i.instagram.com/api/v1/" + (isLoc ? "locations/" : (isHashtag ? "tags/" : "feed/user/")) final String url = "https://" + (storiesig ? "storiesig" : "i.instagram") + ".com/api/v1/"
+ id + "/story/"; + (isLoc ? "locations/" : (isHashtag ? "tags/" : (highlight ? "feed/reels_media?user_ids=" : "feed/user/")))
+ id + (highlight ? "" : (storiesig ? "/reel_media/" : "/story/"));
try { try {
final HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); final HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setInstanceFollowRedirects(false); conn.setInstanceFollowRedirects(false);
conn.setUseCaches(false); conn.setUseCaches(false);
conn.setRequestProperty("User-Agent", Constants.USER_AGENT); conn.setRequestProperty("User-Agent", storiesig ? Constants.A_USER_AGENT : Constants.I_USER_AGENT);
conn.connect(); conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
JSONObject data = new JSONObject(Utils.readFromConnection(conn)).getJSONObject((isLoc || isHashtag) ? "story" : "reel"); JSONObject data = new JSONObject(Utils.readFromConnection(conn));
if (!storiesig && !highlight) data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel");
else if (highlight) data = data.getJSONObject("reels").optJSONObject(id);
if (username == null && !isLoc && !isHashtag) username = data.getJSONObject("user").getString("username");
JSONArray media; JSONArray media;
if ((media = data.optJSONArray("items")) != null && media.length() > 0 && if (data != null && (media = data.optJSONArray("items")) != null
(data = media.optJSONObject(0)) != null) { && media.length() > 0 && (data = media.optJSONObject(0)) != null) {
final int mediaLen = media.length(); final int mediaLen = media.length();

View File

@ -6,6 +6,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -40,16 +41,18 @@ import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR;
import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER; import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER;
import static awais.instagrabber.utils.Constants.FOLDER_PATH; import static awais.instagrabber.utils.Constants.FOLDER_PATH;
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO; import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
import static awais.instagrabber.utils.Constants.INSTADP;
import static awais.instagrabber.utils.Constants.MARK_AS_SEEN; import static awais.instagrabber.utils.Constants.MARK_AS_SEEN;
import static awais.instagrabber.utils.Constants.MUTED_VIDEOS; import static awais.instagrabber.utils.Constants.MUTED_VIDEOS;
import static awais.instagrabber.utils.Constants.SHOW_FEED; import static awais.instagrabber.utils.Constants.SHOW_FEED;
import static awais.instagrabber.utils.Constants.STORIESIG;
import static awais.instagrabber.utils.Utils.settingsHelper; import static awais.instagrabber.utils.Utils.settingsHelper;
public final class SettingsDialog extends BottomSheetDialogFragment implements View.OnClickListener, AdapterView.OnItemSelectedListener, public final class SettingsDialog extends BottomSheetDialogFragment implements View.OnClickListener, AdapterView.OnItemSelectedListener,
CompoundButton.OnCheckedChangeListener { CompoundButton.OnCheckedChangeListener {
private Activity activity; private Activity activity;
private FragmentManager fragmentManager; private FragmentManager fragmentManager;
private View btnSaveTo, btnImportExport, btnLogin, btnLogout, btnTimeSettings, btnReport; private View btnSaveTo, btnImportExport, btnLogin, btnLogout, btnTimeSettings, btnReport, btnPrivacy;
private AppCompatTextView settingTitle; private AppCompatTextView settingTitle;
private Spinner spAppTheme, spLanguage; private Spinner spAppTheme, spLanguage;
private boolean somethingChanged = false; private boolean somethingChanged = false;
@ -94,6 +97,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
btnImportExport = contentView.findViewById(R.id.importExport); btnImportExport = contentView.findViewById(R.id.importExport);
btnTimeSettings = contentView.findViewById(R.id.btnTimeSettings); btnTimeSettings = contentView.findViewById(R.id.btnTimeSettings);
btnReport = contentView.findViewById(R.id.btnReport); btnReport = contentView.findViewById(R.id.btnReport);
btnPrivacy = contentView.findViewById(R.id.btnPrivacy);
Utils.setTooltipText(btnImportExport, R.string.import_export); Utils.setTooltipText(btnImportExport, R.string.import_export);
@ -103,6 +107,7 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
btnSaveTo.setOnClickListener(this); btnSaveTo.setOnClickListener(this);
btnImportExport.setOnClickListener(this); btnImportExport.setOnClickListener(this);
btnTimeSettings.setOnClickListener(this); btnTimeSettings.setOnClickListener(this);
btnPrivacy.setOnClickListener(this);
if (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) btnLogout.setEnabled(false); if (Utils.isEmpty(settingsHelper.getString(Constants.COOKIE))) btnLogout.setEnabled(false);
@ -123,12 +128,16 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
final AppCompatCheckBox cbAutoplayVideos = contentView.findViewById(R.id.cbAutoplayVideos); final AppCompatCheckBox cbAutoplayVideos = contentView.findViewById(R.id.cbAutoplayVideos);
final AppCompatCheckBox cbDownloadUsername = contentView.findViewById(R.id.cbDownloadUsername); final AppCompatCheckBox cbDownloadUsername = contentView.findViewById(R.id.cbDownloadUsername);
final AppCompatCheckBox cbMarkAsSeen = contentView.findViewById(R.id.cbMarkAsSeen); final AppCompatCheckBox cbMarkAsSeen = contentView.findViewById(R.id.cbMarkAsSeen);
final AppCompatCheckBox cbInstadp = contentView.findViewById(R.id.cbInstadp);
final AppCompatCheckBox cbStoriesig = contentView.findViewById(R.id.cbStoriesig);
cbSaveTo.setChecked(settingsHelper.getBoolean(FOLDER_SAVE_TO)); cbSaveTo.setChecked(settingsHelper.getBoolean(FOLDER_SAVE_TO));
cbMuteVideos.setChecked(settingsHelper.getBoolean(MUTED_VIDEOS)); cbMuteVideos.setChecked(settingsHelper.getBoolean(MUTED_VIDEOS));
cbBottomToolbar.setChecked(settingsHelper.getBoolean(BOTTOM_TOOLBAR)); cbBottomToolbar.setChecked(settingsHelper.getBoolean(BOTTOM_TOOLBAR));
cbAutoplayVideos.setChecked(settingsHelper.getBoolean(AUTOPLAY_VIDEOS)); cbAutoplayVideos.setChecked(settingsHelper.getBoolean(AUTOPLAY_VIDEOS));
cbMarkAsSeen.setChecked(settingsHelper.getBoolean(MARK_AS_SEEN)); cbMarkAsSeen.setChecked(settingsHelper.getBoolean(MARK_AS_SEEN));
cbInstadp.setChecked(settingsHelper.getBoolean(INSTADP));
cbStoriesig.setChecked(settingsHelper.getBoolean(STORIESIG));
cbAutoloadPosts.setChecked(settingsHelper.getBoolean(AUTOLOAD_POSTS)); cbAutoloadPosts.setChecked(settingsHelper.getBoolean(AUTOLOAD_POSTS));
cbDownloadUsername.setChecked(settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER)); cbDownloadUsername.setChecked(settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER));
@ -140,6 +149,8 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
setupListener(cbAutoplayVideos); setupListener(cbAutoplayVideos);
setupListener(cbDownloadUsername); setupListener(cbDownloadUsername);
setupListener(cbMarkAsSeen); setupListener(cbMarkAsSeen);
setupListener(cbInstadp);
setupListener(cbStoriesig);
btnSaveTo.setEnabled(cbSaveTo.isChecked()); btnSaveTo.setEnabled(cbSaveTo.isChecked());
@ -183,18 +194,18 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
if (ContextCompat.checkSelfPermission(activity, Utils.PERMS[0]) == PackageManager.PERMISSION_DENIED) if (ContextCompat.checkSelfPermission(activity, Utils.PERMS[0]) == PackageManager.PERMISSION_DENIED)
requestPermissions(Utils.PERMS, 6007); requestPermissions(Utils.PERMS, 6007);
else Utils.showImportExportDialog(activity); else Utils.showImportExportDialog(activity);
} else if (v == btnTimeSettings) { } else if (v == btnTimeSettings) {
new TimeSettingsDialog().show(fragmentManager, null); new TimeSettingsDialog().show(fragmentManager, null);
} else if (v == btnReport) { } else if (v == btnReport) {
CrashReporter.get(activity.getApplication()).zipLogs().startCrashEmailIntent(activity, true); CrashReporter.get(activity.getApplication()).zipLogs().startCrashEmailIntent(activity, true);
} else if (v == btnSaveTo) { } else if (v == btnSaveTo) {
if (ContextCompat.checkSelfPermission(activity, Utils.PERMS[0]) == PackageManager.PERMISSION_DENIED) if (ContextCompat.checkSelfPermission(activity, Utils.PERMS[0]) == PackageManager.PERMISSION_DENIED)
requestPermissions(Utils.PERMS, 6200); requestPermissions(Utils.PERMS, 6200);
else showDirectoryChooser(); else showDirectoryChooser();
} else if (v == btnPrivacy) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://instagrabber.austinhuang.me/disclosure#for-anonymous-users"));
startActivity(intent);
} else if (v instanceof ViewGroup) } else if (v instanceof ViewGroup)
((ViewGroup) v).getChildAt(0).performClick(); ((ViewGroup) v).getChildAt(0).performClick();
} }
@ -208,6 +219,8 @@ public final class SettingsDialog extends BottomSheetDialogFragment implements V
else if (id == R.id.cbMuteVideos) settingsHelper.putBoolean(MUTED_VIDEOS, checked); else if (id == R.id.cbMuteVideos) settingsHelper.putBoolean(MUTED_VIDEOS, checked);
else if (id == R.id.cbAutoloadPosts) settingsHelper.putBoolean(AUTOLOAD_POSTS, checked); else if (id == R.id.cbAutoloadPosts) settingsHelper.putBoolean(AUTOLOAD_POSTS, checked);
else if (id == R.id.cbMarkAsSeen) settingsHelper.putBoolean(MARK_AS_SEEN, checked); else if (id == R.id.cbMarkAsSeen) settingsHelper.putBoolean(MARK_AS_SEEN, checked);
else if (id == R.id.cbInstadp) settingsHelper.putBoolean(INSTADP, checked);
else if (id == R.id.cbStoriesig) settingsHelper.putBoolean(STORIESIG, checked);
else if (id == R.id.cbSaveTo) { else if (id == R.id.cbSaveTo) {
settingsHelper.putBoolean(FOLDER_SAVE_TO, checked); settingsHelper.putBoolean(FOLDER_SAVE_TO, checked);
btnSaveTo.setEnabled(checked); btnSaveTo.setEnabled(checked);

View File

@ -1,11 +1,11 @@
package awais.instagrabber.models; package awais.instagrabber.models;
public final class HighlightModel { public final class HighlightModel {
private final String title, thumbnailUrl; private final String title, id, thumbnailUrl;
private StoryModel[] storyModels;
public HighlightModel(final String title, final String thumbnailUrl) { public HighlightModel(final String title, final String id, final String thumbnailUrl) {
this.title = title; this.title = title;
this.id = id;
this.thumbnailUrl = thumbnailUrl; this.thumbnailUrl = thumbnailUrl;
} }
@ -13,15 +13,11 @@ public final class HighlightModel {
return title; return title;
} }
public String getId() {
return id;
}
public String getThumbnailUrl() { public String getThumbnailUrl() {
return thumbnailUrl; return thumbnailUrl;
} }
public StoryModel[] getStoryModels() {
return storyModels;
}
public void setStoryModels(final StoryModel[] storyModels) {
this.storyModels = storyModels;
}
} }

View File

@ -20,6 +20,8 @@ public final class Constants {
public static final String SHOW_FEED = "show_feed"; public static final String SHOW_FEED = "show_feed";
public static final String CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled"; public static final String CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled";
public static final String MARK_AS_SEEN = "mark_as_seen"; public static final String MARK_AS_SEEN = "mark_as_seen";
public static final String INSTADP = "instadp";
public static final String STORIESIG = "storiesig";
// never Export // never Export
public static final String COOKIE = "cookie"; public static final String COOKIE = "cookie";
public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg"; public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg";
@ -49,6 +51,7 @@ public final class Constants {
"Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)"; "Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)";
public static final String I_USER_AGENT = public static final String I_USER_AGENT =
"Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)"; "Instagram 152.0.0.25.117 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 234847224)";
public static final String A_USER_AGENT = "InstaGrabber.AustinHuang.me / InstaGrabber@AustinHuang.me";
// see https://github.com/dilame/instagram-private-api/blob/master/src/core/constants.ts // 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\":" + public static final String SUPPORTED_CAPABILITIES = "[ { \"name\": \"SUPPORTED_SDK_VERSIONS\", \"value\":" +
" \"13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0," + " \"13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0," +

View File

@ -22,10 +22,12 @@ import static awais.instagrabber.utils.Constants.DEVICE_UUID;
import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER; import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER;
import static awais.instagrabber.utils.Constants.FOLDER_PATH; import static awais.instagrabber.utils.Constants.FOLDER_PATH;
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO; import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
import static awais.instagrabber.utils.Constants.INSTADP;
import static awais.instagrabber.utils.Constants.MARK_AS_SEEN; import static awais.instagrabber.utils.Constants.MARK_AS_SEEN;
import static awais.instagrabber.utils.Constants.MUTED_VIDEOS; import static awais.instagrabber.utils.Constants.MUTED_VIDEOS;
import static awais.instagrabber.utils.Constants.PREV_INSTALL_VERSION; import static awais.instagrabber.utils.Constants.PREV_INSTALL_VERSION;
import static awais.instagrabber.utils.Constants.SHOW_QUICK_ACCESS_DIALOG; import static awais.instagrabber.utils.Constants.SHOW_QUICK_ACCESS_DIALOG;
import static awais.instagrabber.utils.Constants.STORIESIG;
public final class SettingsHelper { public final class SettingsHelper {
private final SharedPreferences sharedPreferences; private final SharedPreferences sharedPreferences;
@ -107,7 +109,7 @@ public final class SettingsHelper {
public @interface StringSettings {} public @interface StringSettings {}
@StringDef({DOWNLOAD_USER_FOLDER, BOTTOM_TOOLBAR, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, @StringDef({DOWNLOAD_USER_FOLDER, BOTTOM_TOOLBAR, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS,
AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN}) AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, INSTADP, STORIESIG})
public @interface BooleanSettings {} public @interface BooleanSettings {}
@StringDef({APP_THEME, APP_LANGUAGE, PREV_INSTALL_VERSION}) @StringDef({APP_THEME, APP_LANGUAGE, PREV_INSTALL_VERSION})

View File

@ -1173,95 +1173,6 @@ public final class Utils {
dialog[0] = new AlertDialog.Builder(context).setView(importExportBinding.getRoot()).show(); dialog[0] = new AlertDialog.Builder(context).setView(importExportBinding.getRoot()).show();
} }
// taken from Arrays.toString()
@NonNull
public static String highlightIdsMerger(final String... strings) {
if (strings != null) {
int iMax = strings.length - 1;
if (iMax != -1) {
final StringBuilder builder = new StringBuilder();
builder.append('[');
for (int i = 0; ; i++) {
builder.append('"').append(strings[i]).append('"');
if (i == iMax) return builder.append(']').toString();
builder.append(',');
}
}
}
return "[]";
}
public static void putHighlightModels(final HttpURLConnection conn, final Object[] model) throws Exception {
final boolean isHighlightModel = model instanceof HighlightModel[];
final boolean isFeedStoryModel = model instanceof FeedStoryModel[];
if (isHighlightModel || isFeedStoryModel) {
final JSONArray highlightsMediaReel = new JSONObject(Utils.readFromConnection(conn)).getJSONObject("data").getJSONArray("reels_media");
final int mediaLength = highlightsMediaReel.length();
for (int i = 0; i < mediaLength; ++i) {
final JSONArray items = highlightsMediaReel.getJSONObject(i).getJSONArray("items");
final int itemsLen = items.length();
final StoryModel[] storyModels = new StoryModel[itemsLen];
for (int j = 0; j < itemsLen; ++j) {
final JSONObject data = items.getJSONObject(j);
final boolean isVideo = data.getBoolean("is_video");
boolean hasTappableObjecs = data.has("tappable_objects");
final JSONArray tappableObjects;
final int tappableLength;
if (hasTappableObjecs) {
tappableObjects = data.getJSONArray("tappable_objects");
tappableLength = tappableObjects.length();
hasTappableObjecs = tappableLength > 0;
} else {
tappableLength = 0;
tappableObjects = null;
}
storyModels[j] = new StoryModel(data.getString(Constants.EXTRAS_ID), data.getString("display_url"),
isVideo ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE,
data.getLong("taken_at_timestamp"), data.getJSONObject("owner").getString("username"),
data.getJSONObject("owner").getString("id"), data.getBoolean("can_reply"));
if (isVideo && data.has("video_resources"))
storyModels[j].setVideoUrl(Utils.getHighQualityPost(data.getJSONArray("video_resources"), true, false, false));
if (!data.isNull("story_app_attribution"))
storyModels[j].setSpotify(data.getJSONObject("story_app_attribution").optString("content_url").split("\\?")[0]);
if (hasTappableObjecs) {
for (int k = 0; k < tappableLength; ++k) {
JSONObject jsonObject = tappableObjects.getJSONObject(k);
if (jsonObject.getString("__typename").equals("GraphTappableFeedMedia") && jsonObject.has("media")) {
storyModels[j].setTappableShortCode(jsonObject.getJSONObject("media").getString(Constants.EXTRAS_SHORTCODE));
}
else if (jsonObject.optString("__typename").equals("GraphTappableStoryPoll") && !jsonObject.isNull("id")) {
storyModels[j].setPoll(new PollModel(
jsonObject.getString("id"),
jsonObject.getString("question"),
jsonObject.getJSONArray("tallies").getJSONObject(0).getString("text"),
jsonObject.getJSONArray("tallies").getJSONObject(0).getInt("count"),
jsonObject.getJSONArray("tallies").getJSONObject(1).getString("text"),
jsonObject.getJSONArray("tallies").getJSONObject(1).getInt("count"),
jsonObject.optInt("viewer_vote", -1)
));
}
}
}
}
if (isHighlightModel)
((HighlightModel[]) model)[i].setStoryModels(storyModels);
else
((FeedStoryModel[]) model)[i].setStoryModels(storyModels);
}
}
}
public static String sign(final String message) { public static String sign(final String message) {
try { try {
Mac hasher = Mac.getInstance("HmacSHA256"); Mac hasher = Mac.getInstance("HmacSHA256");

View File

@ -259,6 +259,17 @@
android:textSize="16sp" /> android:textSize="16sp" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:padding="5dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:text="@string/login_settings"
android:textColor="?android:textColorPrimary"
android:textSize="16sp" />
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -284,6 +295,80 @@
android:textSize="16sp" /> android:textSize="16sp" />
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"
android:padding="5dp">
<androidx.appcompat.widget.AppCompatTextView
android:gravity="center_vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/anonymous_settings"
android:textColor="?android:textColorPrimary"
android:textSize="16sp" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/privacy_warning" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"
android:padding="5dp">
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/cbInstadp"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@string/instadp_settings" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="5dp"
android:text="@string/instadp_settings"
android:textColor="?android:textColorPrimary"
android:textSize="16sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"
android:padding="5dp">
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/cbStoriesig"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@string/storiesig_settings" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="5dp"
android:text="@string/storiesig_settings"
android:textColor="?android:textColorPrimary"
android:textSize="16sp" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -45,6 +45,11 @@
<string name="save_to_folder">Save to custom folder</string> <string name="save_to_folder">Save to custom folder</string>
<string name="select_folder">Select folder</string> <string name="select_folder">Select folder</string>
<string name="theme_settings">Theme Settings</string> <string name="theme_settings">Theme Settings</string>
<string name="login_settings">Only affects logged-in users:</string>
<string name="anonymous_settings">Only affects anonymous users:</string>
<string name="privacy_warning">Privacy</string>
<string name="instadp_settings">Use Instadp for high definition profile pictures</string>
<string name="storiesig_settings">Use storiesig for stories and highlights from public users</string>
<string name="import_export">Import/Export</string> <string name="import_export">Import/Export</string>
<string name="select_language">Select language</string> <string name="select_language">Select language</string>
<string name="what_to_do_dialog">What to do?</string> <string name="what_to_do_dialog">What to do?</string>
@ -67,6 +72,7 @@
<string name="view_story_post">View Post</string> <string name="view_story_post">View Post</string>
<string name="view_post">View Post</string> <string name="view_post">View Post</string>
<string name="spotify">Spotify</string> <string name="spotify">Spotify</string>
<string name="stories_notloggedin">Can\'t interact if y\'ain\'t logged in!</string>
<string name="vote_story_poll">Vote</string> <string name="vote_story_poll">Vote</string>
<string name="votef_story_poll">Vote successful!</string> <string name="votef_story_poll">Vote successful!</string>
<string name="voted_story_poll">You have already voted!</string> <string name="voted_story_poll">You have already voted!</string>

View File

@ -0,0 +1,4 @@
* You can now view public stories and highlights WITHOUT logging in, but only if you enable it in Settings
* Originally, viewing HD avatars without logging in automatically uses Instadp, now you have to enable it in Settings as well
* Consent is important! A button now tells you
* Highlights now support showing sticker infos