From 04d9adbaecfe7e68c46473c7e85cbe34925f874b Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Wed, 12 Aug 2020 14:38:07 -0400 Subject: [PATCH] pt-br init, also discover --- .../main/java/awais/instagrabber/MainHelper.java | 11 +++++------ .../awais/instagrabber/asyncs/DiscoverFetcher.java | 9 +++++---- .../instagrabber/asyncs/i/iStoryStatusFetcher.java | 5 +++-- .../awais/instagrabber/asyncs/i/iTopicFetcher.java | 2 +- .../instagrabber/models/DiscoverTopicModel.java | 8 +++++++- .../java/awais/instagrabber/utils/Constants.java | 4 ++-- .../java/awais/instagrabber/utils/LocaleUtils.java | 1 + app/src/main/res/values-de/arrays.xml | 1 + app/src/main/res/values-es/arrays.xml | 1 + app/src/main/res/values-fr/arrays.xml | 1 + app/src/main/res/values-in/arrays.xml | 1 + app/src/main/res/values-it/arrays.xml | 1 + app/src/main/res/values-pl/arrays.xml | 3 ++- app/src/main/res/values-pt/arrays.xml | 13 +++++++------ app/src/main/res/values-ru/arrays.xml | 1 + app/src/main/res/values-tr/arrays.xml | 1 + app/src/main/res/values-zh/arrays.xml | 7 ++++--- app/src/main/res/values/arrays.xml | 1 + 18 files changed, 45 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/MainHelper.java b/app/src/main/java/awais/instagrabber/MainHelper.java index 7edb9940..95996d10 100755 --- a/app/src/main/java/awais/instagrabber/MainHelper.java +++ b/app/src/main/java/awais/instagrabber/MainHelper.java @@ -92,7 +92,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { private final boolean autoloadPosts; private FeedStoryModel[] stories; private boolean hasNextPage = false, feedHasNextPage = false, discoverHasMore = false; - private String endCursor = null, feedEndCursor = null, discoverEndMaxId = null, topic = null; + private String endCursor = null, feedEndCursor = null, discoverEndMaxId = null, topic = null, rankToken = null; private String[] topicIds = null; private final FetchListener postsFetchListener = new FetchListener() { @Override @@ -197,6 +197,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { public void onResult(final DiscoverTopicModel result) { if (result != null) { topicIds = result.getIds(); + rankToken = result.getToken(); ArrayAdapter spinnerArrayAdapter = new ArrayAdapter( main, android.R.layout.simple_spinner_dropdown_item, result.getNames() ); main.mainBinding.discoverType.setAdapter(spinnerArrayAdapter); @@ -536,7 +537,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { if (discoverLazyLoader != null) discoverLazyLoader.resetState(); main.discoverItems.clear(); if (discoverAdapter != null) discoverAdapter.notifyDataSetChanged(); - new DiscoverFetcher(topic, null, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new DiscoverFetcher(topic, null, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } @@ -549,7 +550,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { if (discoverLazyLoader != null) discoverLazyLoader.resetState(); main.discoverItems.clear(); if (discoverAdapter != null) discoverAdapter.notifyDataSetChanged(); - new DiscoverFetcher(topic, null, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new DiscoverFetcher(topic, null, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }); main.mainBinding.discoverPosts.setAdapter(discoverAdapter = new DiscoverAdapter(main.discoverItems, v -> { @@ -575,12 +576,10 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { main.mainBinding.discoverPosts.addOnScrollListener(discoverLazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> { if (discoverHasMore) { main.mainBinding.discoverSwipeRefreshLayout.setRefreshing(true); - new DiscoverFetcher(topic, discoverEndMaxId, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new DiscoverFetcher(topic, discoverEndMaxId, rankToken, discoverFetchListener, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); discoverEndMaxId = null; } })); - - new DiscoverFetcher(topic, null, discoverFetchListener, true).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } public void onIntent(final Intent intent) { diff --git a/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java index 1ada43ee..4c7c3821 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/DiscoverFetcher.java @@ -31,16 +31,17 @@ import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.settingsHelper; public final class DiscoverFetcher extends AsyncTask { - private final String cluster, maxId; + private final String cluster, maxId, rankToken; private final FetchListener fetchListener; private int lastId = 0; private boolean isFirst, moreAvailable; private String nextMaxId; - public DiscoverFetcher(final String cluster, final String maxId, + public DiscoverFetcher(final String cluster, final String maxId, final String rankToken, final FetchListener fetchListener, final boolean isFirst) { this.cluster = cluster == null ? "explore_all%3A0" : cluster.replace(":", "%3A"); this.maxId = maxId == null ? "" : "&max_id=" + maxId; + this.rankToken = rankToken; this.fetchListener = fetchListener; this.isFirst = isFirst; } @@ -66,12 +67,12 @@ public final class DiscoverFetcher extends AsyncTask fetchItems(ArrayList discoverItemModels, final String maxId) { try { final String url = "https://www.instagram.com/explore/grid/?is_prefetch=false&omit_cover_media=true&module=explore_popular" + - "&use_sectional_payload=false&cluster_id="+cluster+"&include_fixed_destinations=true" + maxId; + "&use_sectional_payload=false&cluster_id="+cluster+"&include_fixed_destinations=true&session_id="+rankToken+maxId; final HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection(); urlConnection.setUseCaches(false); - urlConnection.setRequestProperty("User-Agent", Constants.USER_AGENT); + urlConnection.setRequestProperty("User-Agent", Constants.I_USER_AGENT); if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { final JSONObject discoverResponse = new JSONObject(Utils.readFromConnection(urlConnection)); diff --git a/app/src/main/java/awais/instagrabber/asyncs/i/iStoryStatusFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/i/iStoryStatusFetcher.java index 1b0e1938..919f761e 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/i/iStoryStatusFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/i/iStoryStatusFetcher.java @@ -103,10 +103,11 @@ public final class iStoryStatusFetcher extends AsyncTaskDeutsch [Danke an @peterge1998 (GitHub)] Polnisch [Danke an @Lego8486 (GitHub)] Türkisch [Danke an @faydin90 (Telegram)] + BR Portugiesisch [Danke an @wagnim (GitHub)] Auto / Folge System diff --git a/app/src/main/res/values-es/arrays.xml b/app/src/main/res/values-es/arrays.xml index cf6becb2..06348da5 100755 --- a/app/src/main/res/values-es/arrays.xml +++ b/app/src/main/res/values-es/arrays.xml @@ -11,6 +11,7 @@ Alemán [Gracias a @peterge1998 (GitHub)] Polaco [Gracias a @Lego8486 (GitHub)] Turco [Gracias a @faydin90 (Telegram)] + Portugués brasileño [Gracias a @wagnim (GitHub)] Auto / Seguir Sistema diff --git a/app/src/main/res/values-fr/arrays.xml b/app/src/main/res/values-fr/arrays.xml index d4bbc0e5..f44192e9 100755 --- a/app/src/main/res/values-fr/arrays.xml +++ b/app/src/main/res/values-fr/arrays.xml @@ -11,6 +11,7 @@ Allemand [Merci à @peterge1998 (GitHub)] Polonais [Merci à @Lego8486 (GitHub)] Turc [Merci à @faydin90 (Telegram)] + Portugais brésilien [Merci à @wagnim (GitHub)] Automatique (Système) diff --git a/app/src/main/res/values-in/arrays.xml b/app/src/main/res/values-in/arrays.xml index c4e8cb6c..5fc6c52d 100644 --- a/app/src/main/res/values-in/arrays.xml +++ b/app/src/main/res/values-in/arrays.xml @@ -11,6 +11,7 @@ Jerman [Terima kasih @peterge1998 (GitHub)] Polandia [Terima kasih @Lego8486 (GitHub)] Turki [Terima kasih @faydin90 (Telegram)] + Portugis Brasil [Terima kasih @wagnim (GitHub)] Otomatis / Ikuti Sistem diff --git a/app/src/main/res/values-it/arrays.xml b/app/src/main/res/values-it/arrays.xml index c4396e40..d168559a 100755 --- a/app/src/main/res/values-it/arrays.xml +++ b/app/src/main/res/values-it/arrays.xml @@ -11,6 +11,7 @@ Tedesco [Grazie a @peterge1998 (GitHub)] Polacco [Grazie a @Lego8486 (GitHub)] Turco [Grazie a @faydin90 (Telegram)] + Portoghese [Grazie a @wagnim (Telegram)] Automatico / In base al sistema diff --git a/app/src/main/res/values-pl/arrays.xml b/app/src/main/res/values-pl/arrays.xml index 8877248b..67b3e52e 100644 --- a/app/src/main/res/values-pl/arrays.xml +++ b/app/src/main/res/values-pl/arrays.xml @@ -10,7 +10,8 @@ Włoski [Podziękowania dla @RAR_Ramar (Telegram)] Niemiecki [Podziękowania dla @peterge1998 (GitHub)] Polski [Podziękowania dla @Lego8486 (GitHub)] - Turkish [Thanks to @faydin90 (Telegram)] + Turecki [Podziękowania dla @faydin90 (Telegram)] + Portugalski [Podziękowania dla @wagnim (GitHub)] Auto / Ustawienia systemu diff --git a/app/src/main/res/values-pt/arrays.xml b/app/src/main/res/values-pt/arrays.xml index ff676c4a..0a1a6b55 100644 --- a/app/src/main/res/values-pt/arrays.xml +++ b/app/src/main/res/values-pt/arrays.xml @@ -3,14 +3,15 @@ Padrão do sistema Inglês - Francês Agradecimentos a @kernoeb (Telegram)] - Espanhol Agradecimentos a @sguinetti (GitLab)] + Francês [Agradecimentos a @kernoeb (Telegram)] + Espanhol [Agradecimentos a @sguinetti (GitLab)] Chinês (Simplificado) - Indonésio [Agradecimentos a @ Galang23 (GitLab)] + Indonésio [Agradecimentos a @Galang23 (GitLab)] Italiano [Agradecimentos a @RAR_Ramar (Telegram)] - Alemão [Agradecimentos a @ peterge1998 (GitHub)] - Polonês [Agradecimentos a @ Lego8486 (GitHub)] - Turco [Agradecimentos a @ faydin90 (Telegram)] + Alemão [Agradecimentos a @peterge1998 (GitHub)] + Polonês [Agradecimentos a @Lego8486 (GitHub)] + Turco [Agradecimentos a @faydin90 (Telegram)] + Português (BR) [Agradecimentos a @wagnim (GitHub)] Auto / Seguir o sistema diff --git a/app/src/main/res/values-ru/arrays.xml b/app/src/main/res/values-ru/arrays.xml index ef179601..0c1f996b 100644 --- a/app/src/main/res/values-ru/arrays.xml +++ b/app/src/main/res/values-ru/arrays.xml @@ -11,6 +11,7 @@ German [Thanks to @peterge1998 (GitHub)] Polish [Thanks to @Lego8486 (GitHub)] Turkish [Thanks to @faydin90 (Telegram)] + Portuguese (BR) [Thanks to @wagnim (GitHub)] Auto / Follow System diff --git a/app/src/main/res/values-tr/arrays.xml b/app/src/main/res/values-tr/arrays.xml index 79750cef..d7fe2b86 100644 --- a/app/src/main/res/values-tr/arrays.xml +++ b/app/src/main/res/values-tr/arrays.xml @@ -11,6 +11,7 @@ Almanca [@peterge1998 (GitHub) sayesinde] Lehçe [@Lego8486 (GitHub) sayesinde] Türkçe [@faydin90 (Telegram) sayesinde] + Portekizce [@wagnim (GitHub) sayesinde] Otomatik / Sistemi Takip Et diff --git a/app/src/main/res/values-zh/arrays.xml b/app/src/main/res/values-zh/arrays.xml index 4a92cbed..6897f5fb 100755 --- a/app/src/main/res/values-zh/arrays.xml +++ b/app/src/main/res/values-zh/arrays.xml @@ -10,13 +10,14 @@ 意大利文 [感谢 @RAR_Ramar (Telegram)] 德文 [感谢 @peterge1998 (GitHub)] 波兰文 [感谢 @Lego8486 (GitHub)] - 土耳其语 [感谢 @faydin90 (Telegram)] + 土耳其文 [感谢 @faydin90 (Telegram)] + 巴西葡文 [感谢 @wagnim (GitHub)] 自动 / 跟随系统 自动 / 跟随电池 - 暗黑 - 明亮 + 夜间模式 + 明亮模式 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index ef179601..c71271a2 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -11,6 +11,7 @@ German [Thanks to @peterge1998 (GitHub)] Polish [Thanks to @Lego8486 (GitHub)] Turkish [Thanks to @faydin90 (Telegram)] + Brazilian Portuguese [Thanks to @wagnim (GitHub)] Auto / Follow System