Browse Source

byebye storiesig

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
6425fc3975
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 8
      app/src/main/java/awais/instagrabber/asyncs/HighlightsFetcher.java
  2. 19
      app/src/main/java/awais/instagrabber/asyncs/i/iStoryStatusFetcher.java
  3. 2
      app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java
  4. 1
      app/src/main/java/awais/instagrabber/fragments/LocationFragment.java
  5. 1
      app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java
  6. 4
      app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
  7. 5
      app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java
  8. 22
      app/src/main/java/awais/instagrabber/webservices/StoriesService.java
  9. 1
      app/src/main/res/values-de/arrays.xml
  10. 1
      app/src/main/res/values-es/arrays.xml
  11. 1
      app/src/main/res/values-fa/arrays.xml
  12. 1
      app/src/main/res/values-fr/arrays.xml
  13. 1
      app/src/main/res/values-in/arrays.xml
  14. 1
      app/src/main/res/values-it/arrays.xml
  15. 1
      app/src/main/res/values-mk/arrays.xml
  16. 1
      app/src/main/res/values-pl/arrays.xml
  17. 1
      app/src/main/res/values-pt/arrays.xml
  18. 1
      app/src/main/res/values-ru/arrays.xml
  19. 1
      app/src/main/res/values-tr/arrays.xml
  20. 1
      app/src/main/res/values-zh/arrays.xml
  21. 1
      app/src/main/res/values/arrays.xml

8
app/src/main/java/awais/instagrabber/asyncs/HighlightsFetcher.java

@ -19,25 +19,23 @@ import awais.instagrabber.utils.NetworkUtils;
public final class HighlightsFetcher extends AsyncTask<Void, Void, List<HighlightModel>> { public final class HighlightsFetcher extends AsyncTask<Void, Void, List<HighlightModel>> {
private final String id; private final String id;
private final boolean storiesig;
private final FetchListener<List<HighlightModel>> fetchListener; private final FetchListener<List<HighlightModel>> fetchListener;
public HighlightsFetcher(final String id, final boolean storiesig, final FetchListener<List<HighlightModel>> fetchListener) {
public HighlightsFetcher(final String id, final FetchListener<List<HighlightModel>> fetchListener) {
this.id = id; this.id = id;
this.storiesig = storiesig;
this.fetchListener = fetchListener; this.fetchListener = fetchListener;
} }
@Override @Override
protected List<HighlightModel> doInBackground(final Void... voids) { protected List<HighlightModel> doInBackground(final Void... voids) {
List<HighlightModel> result = null; List<HighlightModel> result = null;
String url = "https://" + (storiesig ? "storiesig" : "i.instagram") + ".com/api/v1/highlights/" + id + "/highlights_tray/";
String url = "https://i.instagram.com/api/v1/highlights/" + id + "/highlights_tray/";
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.setRequestProperty("User-Agent", Constants.I_USER_AGENT);
conn.connect(); conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {

19
app/src/main/java/awais/instagrabber/asyncs/i/iStoryStatusFetcher.java

@ -30,7 +30,6 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
private String username; private String username;
private final boolean isLoc; private final boolean isLoc;
private final boolean isHashtag; private final boolean isHashtag;
private final boolean storiesig;
private final boolean highlight; private final boolean highlight;
private final FetchListener<StoryModel[]> fetchListener; private final FetchListener<StoryModel[]> fetchListener;
@ -38,14 +37,12 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
final String username, final String username,
final boolean isLoc, final boolean isLoc,
final boolean isHashtag, final boolean isHashtag,
final boolean storiesig,
final boolean highlight, final boolean highlight,
final FetchListener<StoryModel[]> fetchListener) { 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.highlight = highlight;
this.fetchListener = fetchListener; this.fetchListener = fetchListener;
} }
@ -55,13 +52,7 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
StoryModel[] result = null; StoryModel[] result = null;
final String userId = id.replace(":", "%3A"); final String userId = id.replace(":", "%3A");
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("https://");
if (storiesig) {
builder.append("storiesig");
} else {
builder.append("i.instagram");
}
builder.append(".com/api/v1/");
builder.append("https://i.instagram.com/api/v1/");
if (isLoc) { if (isLoc) {
builder.append("locations/"); builder.append("locations/");
} }
@ -75,24 +66,20 @@ public final class iStoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[
} }
builder.append(userId); builder.append(userId);
if (!highlight) { if (!highlight) {
if (storiesig) {
builder.append("/reel_media/");
} else {
builder.append("/story/"); builder.append("/story/");
} }
}
final String url = builder.toString(); final String url = builder.toString();
try { try {
final HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); final HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setInstanceFollowRedirects(true); conn.setInstanceFollowRedirects(true);
conn.setUseCaches(false); conn.setUseCaches(false);
conn.setRequestProperty("User-Agent", storiesig ? Constants.A_USER_AGENT : Constants.I_USER_AGENT);
conn.setRequestProperty("User-Agent", Constants.I_USER_AGENT);
conn.setRequestProperty("Accept-Language", LocaleUtils.getCurrentLocale().getLanguage() + ",en-US;q=0.8"); conn.setRequestProperty("Accept-Language", LocaleUtils.getCurrentLocale().getLanguage() + ",en-US;q=0.8");
conn.connect(); conn.connect();
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
JSONObject data = new JSONObject(NetworkUtils.readFromConnection(conn)); JSONObject data = new JSONObject(NetworkUtils.readFromConnection(conn));
if (!storiesig && !highlight)
if (!highlight)
data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel"); data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel");
else if (highlight) data = data.getJSONObject("reels").optJSONObject(id); else if (highlight) data = data.getJSONObject("reels").optJSONObject(id);

2
app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java

@ -286,7 +286,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
final Context context = getContext(); final Context context = getContext();
if (context == null) return; if (context == null) return;
if (isLoggedIn) { if (isLoggedIn) {
new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, false, stories -> {
new iStoryStatusFetcher(hashtagModel.getName(), null, false, true, false, stories -> {
if (stories != null && stories.length > 0) { if (stories != null && stories.length > 0) {
binding.mainHashtagImage.setStoriesBorder(); binding.mainHashtagImage.setStoriesBorder();
} }

1
app/src/main/java/awais/instagrabber/fragments/LocationFragment.java

@ -293,7 +293,6 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
true, true,
false, false,
false, false,
false,
stories -> { stories -> {
if (stories != null && stories.length > 0) { if (stories != null && stories.length > 0) {
binding.mainLocationImage.setStoriesBorder(); binding.mainLocationImage.setStoriesBorder();

1
app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java

@ -544,7 +544,6 @@ public class StoryViewerFragment extends Fragment {
}; };
storiesService.getUserStory(currentStoryMediaId, storiesService.getUserStory(currentStoryMediaId,
username, username,
!isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(),
false, false,
false, false,
isHighlight, isHighlight,

4
app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java

@ -441,12 +441,11 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
final String profileId = profileModel.getId(); final String profileId = profileModel.getId();
if (settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.STORIESIG.getValue()) || isLoggedIn) {
if (isLoggedIn) {
new iStoryStatusFetcher(profileId, new iStoryStatusFetcher(profileId,
profileModel.getUsername(), profileModel.getUsername(),
false, false,
false, false,
!isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.STORIESIG.getValue()),
false, false,
result -> { result -> {
storyModels = result; storyModels = result;
@ -455,7 +454,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new HighlightsFetcher(profileId, new HighlightsFetcher(profileId,
!isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.STORIESIG.getValue()),
result -> { result -> {
if (result != null) { if (result != null) {
binding.highlightsList.setVisibility(View.VISIBLE); binding.highlightsList.setVisibility(View.VISIBLE);

5
app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java

@ -4,9 +4,8 @@ import java.io.Serializable;
public enum StoryViewerChoice implements Serializable { public enum StoryViewerChoice implements Serializable {
NONE(0), NONE(0),
STORIESIG(1),
ALOINSTAGRAM(2),
INSTADP(3);
ALOINSTAGRAM(1),
INSTADP(2);
private int value; private int value;

22
app/src/main/java/awais/instagrabber/webservices/StoriesService.java

@ -98,14 +98,12 @@ public class StoriesService extends BaseService {
public void getUserStory(final String id, public void getUserStory(final String id,
final String username, final String username,
final boolean storiesig,
final boolean isLoc, final boolean isLoc,
final boolean isHashtag, final boolean isHashtag,
final boolean highlight, final boolean highlight,
final ServiceCallback<List<StoryModel>> callback) { final ServiceCallback<List<StoryModel>> callback) {
final String url = buildUrl(id, storiesig, isLoc, isHashtag, highlight);
final String userAgent = storiesig ? Constants.A_USER_AGENT : Constants.I_USER_AGENT;
final Call<String> userStoryCall = repository.getUserStory(userAgent, url);
final String url = buildUrl(id, isLoc, isHashtag, highlight);
final Call<String> userStoryCall = repository.getUserStory(Constants.I_USER_AGENT, url);
userStoryCall.enqueue(new Callback<String>() { userStoryCall.enqueue(new Callback<String>() {
@Override @Override
public void onResponse(@NonNull final Call<String> call, @NonNull final Response<String> response) { public void onResponse(@NonNull final Call<String> call, @NonNull final Response<String> response) {
@ -119,7 +117,7 @@ public class StoriesService extends BaseService {
} }
data = new JSONObject(body); data = new JSONObject(body);
if (!storiesig && !highlight)
if (!highlight)
data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel"); data = data.optJSONObject((isLoc || isHashtag) ? "story" : "reel");
else if (highlight) data = data.getJSONObject("reels").optJSONObject(id); else if (highlight) data = data.getJSONObject("reels").optJSONObject(id);
@ -243,16 +241,10 @@ public class StoriesService extends BaseService {
}); });
} }
private String buildUrl(final String id, final boolean storiesig, final boolean isLoc, final boolean isHashtag, final boolean highlight) {
private String buildUrl(final String id, final boolean isLoc, final boolean isHashtag, final boolean highlight) {
final String userId = id.replace(":", "%3A"); final String userId = id.replace(":", "%3A");
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("https://");
if (storiesig) {
builder.append("storiesig");
} else {
builder.append("i.instagram");
}
builder.append(".com/api/v1/");
builder.append("https://i.instagram.com/api/v1/");
if (isLoc) { if (isLoc) {
builder.append("locations/"); builder.append("locations/");
} }
@ -266,12 +258,8 @@ public class StoriesService extends BaseService {
} }
builder.append(userId); builder.append(userId);
if (!highlight) { if (!highlight) {
if (storiesig) {
builder.append("/reel_media/");
} else {
builder.append("/story/"); builder.append("/story/");
} }
}
return builder.toString(); return builder.toString();
} }
} }

1
app/src/main/res/values-de/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Deaktivieren</item> <item>Deaktivieren</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-es/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-fa/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>غیرفعال</item> <item>غیرفعال</item>
<item>استوری های ig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-fr/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-in/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Nonaktifkan</item> <item>Nonaktifkan</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-it/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disattiva</item> <item>Disattiva</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-mk/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-pl/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-pt/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-ru/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-tr/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Devredışı Bırak</item> <item>Devredışı Bırak</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values-zh/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>禁用</item> <item>禁用</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

1
app/src/main/res/values/arrays.xml

@ -42,7 +42,6 @@
</string-array> </string-array>
<string-array name="anonymous_story_viewer"> <string-array name="anonymous_story_viewer">
<item>Disable</item> <item>Disable</item>
<item>storiesig</item>
<item>Aloinstagram</item> <item>Aloinstagram</item>
<item>Instadp</item> <item>Instadp</item>
</string-array> </string-array>

Loading…
Cancel
Save