1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00
This commit is contained in:
Austin Huang 2020-08-04 10:43:53 -04:00
parent 8421b498bb
commit 5baf2701b0
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
9 changed files with 35 additions and 124 deletions

View File

@ -12,8 +12,8 @@ android {
// REMEMBER TO CHANGE versionCode AS WELL
// 16.7 is 32, 16.9 is 35 (34 is public beta)
versionCode 37
versionName '17.1'
versionCode 38
versionName '17.2'
multiDexEnabled true

View File

@ -238,15 +238,19 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
final Object tag = v.getTag();
if (tag instanceof FeedStoryModel) {
final FeedStoryModel feedStoryModel = (FeedStoryModel) tag;
StoryModel[] storyModels = feedStoryModel.getStoryModels();
final int index = indexOfIntArray(stories, feedStoryModel);
new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, result -> {
if (result != null && result.length > 0)
main.startActivity(new Intent(main, StoryViewer.class)
.putExtra(Constants.EXTRAS_STORIES, result)
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
.putExtra(Constants.FEED, stories)
.putExtra(Constants.FEED_ORDER, index)
);
else Toast.makeText(main, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
main.startActivity(new Intent(main, StoryViewer.class)
.putExtra(Constants.EXTRAS_STORIES, storyModels)
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
.putExtra(Constants.FEED, stories)
.putExtra(Constants.FEED_ORDER, index)
);
}
}
});

View File

@ -48,7 +48,7 @@ public final class DirectMessages extends BaseLanguageActivity implements SwipeR
// todo get request / unseen count from inboxModel
final InboxThreadModel[] threads = inboxModel.getThreads();
if (threads != null) {
if (threads != null && threads.length > 0) {
final int oldSize = inboxThreadModelList.size();
inboxThreadModelList.addAll(Arrays.asList(threads));

View File

@ -55,6 +55,7 @@ import awais.instagrabber.BuildConfig;
import awais.instagrabber.R;
import awais.instagrabber.adapters.StoriesAdapter;
import awais.instagrabber.asyncs.DownloadAsync;
import awais.instagrabber.asyncs.i.iStoryStatusFetcher;
import awais.instagrabber.customviews.helpers.SwipeGestureListener;
import awais.instagrabber.databinding.ActivityStoryViewerBinding;
import awais.instagrabber.interfaces.SwipeEvent;
@ -150,14 +151,18 @@ public final class StoryViewer extends BaseLanguageActivity {
(index == 0 ? null : storyFeed[index - 1]) :
(storyFeed.length == index + 1 ? null : storyFeed[index + 1]);
if (feedStoryModel != null) {
final StoryModel[] nextStoryModels = feedStoryModel.getStoryModels();
final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class)
.putExtra(Constants.EXTRAS_STORIES, nextStoryModels)
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
.putExtra(Constants.FEED, storyFeed)
.putExtra(Constants.FEED_ORDER, isRightSwipe ? (index - 1) : (index + 1));
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(newIntent);
new iStoryStatusFetcher(feedStoryModel.getStoryMediaId(), null, false, false, result -> {
if (result != null && result.length > 0) {
final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class)
.putExtra(Constants.EXTRAS_STORIES, result)
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
.putExtra(Constants.FEED, storyFeed)
.putExtra(Constants.FEED_ORDER, isRightSwipe ? (index - 1) : (index + 1));
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(newIntent);
}
else Toast.makeText(getApplicationContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
}

View File

@ -67,24 +67,6 @@ public final class FeedStoriesFetcher extends AsyncTask<Void, Void, FeedStoryMod
feedStoryIDs[i] = id;
feedStoryModels[i] = new FeedStoryModel(id, profileModel);
}
for (int s = 0; s <= Math.ceil(feedStoryIDs.length / 20); ++s) {
String[] shard = new String[Math.min(20, (feedStoryIDs.length - s*20))];
FeedStoryModel[] feedStoryShard = new FeedStoryModel[Math.min(20, (feedStoryIDs.length - s*20))];
System.arraycopy(feedStoryIDs, s*20, shard, 0, shard.length);
System.arraycopy(feedStoryModels, s*20, feedStoryShard, 0, shard.length);
url = "https://i.instagram.com/api/v1/feed/reels_media/?reel_ids=" + Utils.iHighlightIdsMerger(shard);
conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestProperty("User-Agent", Constants.USER_AGENT);
conn.setInstanceFollowRedirects(false);
conn.setUseCaches(false);
conn.setReadTimeout(2000);
conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
Utils.iPutFeedStoryModels(conn, feedStoryShard, shard);
}
}
result = feedStoryModels;
}

View File

@ -13,6 +13,7 @@ import awais.instagrabber.BuildConfig;
import awais.instagrabber.interfaces.FetchListener;
import awais.instagrabber.models.NotificationModel;
import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.LocaleUtils;
import awais.instagrabber.utils.Utils;
import awaisomereport.LogCollector;
@ -34,6 +35,7 @@ public final class NotificationsFetcher extends AsyncTask<Void, Void, Notificati
final HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setInstanceFollowRedirects(false);
conn.setUseCaches(false);
conn.setRequestProperty("Accept-Language", LocaleUtils.getCurrentLocale().getLanguage() + ",en-US;q=0.8");
conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {

View File

@ -1160,23 +1160,6 @@ public final class Utils {
return "[]";
}
@NonNull
public static String iHighlightIdsMerger(final String... strings) {
if (strings != null) {
int iMax = strings.length - 1;
if (iMax != -1) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; ; i++) {
builder.append(strings[i]);
if (i == iMax) return builder.toString();
builder.append("&reel_ids=");
}
}
}
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[];
@ -1246,75 +1229,6 @@ public final class Utils {
}
}
public static void iPutFeedStoryModels(final HttpURLConnection conn, final FeedStoryModel[] model, final String[] ids) throws Exception {
final JSONObject highlightsMediaReel = new JSONObject(Utils.readFromConnection(conn)).getJSONObject("reels");
final int mediaLength = highlightsMediaReel.length();
for (int i = 0; i < mediaLength; ++i) {
final JSONArray items = highlightsMediaReel.getJSONObject(ids[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.has("video_duration");
storyModels[j] = new StoryModel(data.getString("pk"),
data.getJSONObject("image_versions2").getJSONArray("candidates").getJSONObject(0).getString("url"),
isVideo ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE,
data.optLong("taken_at", 0),
model[i].getProfileModel().getUsername());
final JSONArray videoResources = data.optJSONArray("video_versions");
if (isVideo && videoResources != null)
storyModels[j].setVideoUrl(Utils.getHighQualityPost(videoResources, true, true));
if (data.has("story_feed_media")) {
storyModels[j].setTappableShortCode(data.getJSONArray("story_feed_media").getJSONObject(0).optString("media_id"));
}
if (!data.isNull("story_app_attribution"))
storyModels[j].setSpotify(data.getJSONObject("story_app_attribution").optString("content_url").split("\\?")[0]);
if (data.has("story_polls")) {
JSONObject tappableObject = data.optJSONArray("story_polls").getJSONObject(0).optJSONObject("poll_sticker");
if (tappableObject != null) storyModels[j].setPoll(new PollModel(
String.valueOf(tappableObject.getLong("poll_id")),
tappableObject.getString("question"),
tappableObject.getJSONArray("tallies").getJSONObject(0).getString("text"),
tappableObject.getJSONArray("tallies").getJSONObject(0).getInt("count"),
tappableObject.getJSONArray("tallies").getJSONObject(1).getString("text"),
tappableObject.getJSONArray("tallies").getJSONObject(1).getInt("count"),
tappableObject.optInt("viewer_vote", -1)
));
}
if (data.has("story_questions")) {
JSONObject tappableObject = data.getJSONArray("story_questions").getJSONObject(0).optJSONObject("question_sticker");
if (tappableObject != null) storyModels[j].setQuestion(new QuestionModel(
String.valueOf(tappableObject.getLong("question_id")),
tappableObject.getString("question")
));
}
JSONArray hashtags = data.optJSONArray("story_hashtags");
JSONArray atmarks = data.optJSONArray("reel_mentions");
String[] mentions = new String[(hashtags == null ? 0 : hashtags.length()) + (atmarks == null ? 0 : atmarks.length())];
if (hashtags != null) {
for (int h = 0; h < hashtags.length(); ++h) {
mentions[h] = "#"+hashtags.getJSONObject(h).getJSONObject("hashtag").getString("name");
}
}
if (atmarks != null) {
for (int h = 0; h < atmarks.length(); ++h) {
mentions[h + (hashtags == null ? 0 : hashtags.length())] =
"@"+atmarks.getJSONObject(h).getJSONObject("user").getString("username");
}
}
storyModels[j].setMentions(mentions);
}
model[i].setStoryModels(storyModels);
}
}
public static String sign(final String message) {
try {
Mac hasher = Mac.getInstance("HmacSHA256");

View File

@ -58,7 +58,7 @@
<string name="post_viewer_download_album">整个图集</string>
<string name="show_stories">显示快拍</string>
<string name="no_more_stories">到底啦!</string>
<string name="view_story_post">浏览快拍</string>
<string name="view_story_post">浏览帖子</string>
<string name="view_post">查看帖子</string>
<string name="spotify">Spotify</string>
<string name="vote_story_poll">投票</string>
@ -185,4 +185,8 @@
<string name="updated">感谢阁下更新InstaGrabber</string>
<string name="crash_title">应用崩溃了</string>
<string name="crash_descr">糟糕.. 应用崩溃了,不过别担心,你可以向开发者发送错误报告来帮助他修复问题。(:</string>
<string name="answer_story">回答</string>
<string name="answer_hint">在此回答...</string>
<string name="answered_story">回答完成!</string>
<string name="story_mentions">提及</string>
</resources>

View File

@ -61,7 +61,7 @@
<string name="post_viewer_download_album">Whole Album</string>
<string name="show_stories">Show stories</string>
<string name="no_more_stories">No more stories!</string>
<string name="view_story_post">View Story Post</string>
<string name="view_story_post">View Post</string>
<string name="view_post">View Post</string>
<string name="spotify">Spotify</string>
<string name="vote_story_poll">Vote</string>