From 26531198cb6ce2004b15111a61a43e59398e3d5d Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sat, 2 Jan 2021 13:27:36 -0500 Subject: [PATCH 1/2] remove instadp and jsoup --- app/build.gradle | 2 - .../asyncs/ProfilePictureFetcher.java | 93 ------------------- .../dialogs/ProfilePicDialogFragment.java | 24 +---- .../fragments/FavoritesFragment.java | 2 - .../fragments/settings/AboutFragment.java | 17 ---- .../settings/SettingsPreferencesFragment.java | 23 ++--- .../awais/instagrabber/utils/Constants.java | 2 +- .../instagrabber/utils/SettingsHelper.java | 3 +- 8 files changed, 13 insertions(+), 153 deletions(-) delete mode 100755 app/src/main/java/awais/instagrabber/asyncs/ProfilePictureFetcher.java diff --git a/app/build.gradle b/app/build.gradle index 1148dfc3..454e38ad 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,10 +86,8 @@ dependencies { implementation "androidx.room:room-guava:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version" - // implementation 'com.github.hendrawd:StorageUtil:1.1.0' implementation 'me.austinhuang:AutoLinkTextViewV2:-SNAPSHOT' - implementation 'org.jsoup:jsoup:1.13.1' implementation 'com.facebook.fresco:fresco:2.3.0' implementation 'com.facebook.fresco:animated-webp:2.3.0' implementation 'com.facebook.fresco:webpsupport:2.3.0' diff --git a/app/src/main/java/awais/instagrabber/asyncs/ProfilePictureFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/ProfilePictureFetcher.java deleted file mode 100755 index 433697de..00000000 --- a/app/src/main/java/awais/instagrabber/asyncs/ProfilePictureFetcher.java +++ /dev/null @@ -1,93 +0,0 @@ -package awais.instagrabber.asyncs; - -import android.os.AsyncTask; -import android.util.Log; - -import org.json.JSONObject; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import java.net.HttpURLConnection; -import java.net.URL; - -import awais.instagrabber.BuildConfig; -import awais.instagrabber.interfaces.FetchListener; -import awais.instagrabber.utils.Constants; -import awais.instagrabber.utils.NetworkUtils; -import awais.instagrabber.utils.TextUtils; -import awais.instagrabber.utils.Utils; -import awaisomereport.LogCollector; - -import static awais.instagrabber.utils.Utils.logCollector; - -public final class ProfilePictureFetcher extends AsyncTask { - private final FetchListener fetchListener; - private final String userName, userId, picUrl; - private final boolean isHashtag; - - public ProfilePictureFetcher(final String userName, final String userId, final FetchListener fetchListener, - final String picUrl, final boolean isHashtag) { - this.fetchListener = fetchListener; - this.userName = userName; - this.userId = userId; - this.picUrl = picUrl; - this.isHashtag = isHashtag; - } - - @Override - protected String doInBackground(final Void... voids) { - String out = null; - if (isHashtag) out = picUrl; - else if (Utils.settingsHelper.getBoolean(Constants.INSTADP)) try { - final HttpURLConnection backup = - (HttpURLConnection) new URL("https://instadp.com/fullsize/" + userName).openConnection(); - backup.setUseCaches(false); - backup.setRequestMethod("GET"); - backup.setRequestProperty("User-Agent", Constants.A_USER_AGENT); - - final String instadp = backup.getResponseCode() == HttpURLConnection.HTTP_OK ? NetworkUtils.readFromConnection(backup) : null; - backup.disconnect(); - - if (!TextUtils.isEmpty(instadp)) { - final Document doc = Jsoup.parse(instadp); - boolean fallback = false; - - final int imgIndex = instadp.indexOf("preloadImg('"), lastIndex; - - Element element = doc.selectFirst(".instadp"); - if (element != null && (element = element.selectFirst(".picture")) != null) - out = element.attr("src"); - else if ((element = doc.selectFirst(".download-btn")) != null) - out = element.attr("href"); - else if (imgIndex != -1 && (lastIndex = instadp.indexOf("')", imgIndex)) != -1) - out = instadp.substring(imgIndex + 12, lastIndex); - else { - final Elements imgs = doc.getElementsByTag("img"); - for (final Element img : imgs) { - final String imgStr = img.toString(); - if (imgStr.contains("cdninstagram.com")) out = img.attr("src"); - } - } - } - if (TextUtils.isEmpty(out)) out = picUrl; - } catch (final Exception e) { - if (logCollector != null) - logCollector.appendException(e, LogCollector.LogFile.ASYNC_PROFILE_PICTURE_FETCHER, "doInBackground"); - if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); - } - - return out; - } - - @Override - protected void onPreExecute() { - if (fetchListener != null) fetchListener.doBefore(); - } - - @Override - protected void onPostExecute(final String result) { - if (fetchListener != null) fetchListener.onResult(result); - } -} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java b/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java index 91779710..b1599a35 100644 --- a/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java +++ b/app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java @@ -6,10 +6,8 @@ import android.content.pm.PackageManager; import android.graphics.Color; import android.graphics.drawable.Animatable; import android.graphics.drawable.ColorDrawable; -import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -20,7 +18,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.FragmentActivity; import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.controller.BaseControllerListener; @@ -30,12 +27,7 @@ import com.facebook.imagepipeline.image.ImageInfo; import java.io.File; import awais.instagrabber.R; -import awais.instagrabber.asyncs.ProfilePictureFetcher; import awais.instagrabber.databinding.DialogProfilepicBinding; -import awais.instagrabber.db.entities.Account; -import awais.instagrabber.db.repositories.RepositoryCallback; -import awais.instagrabber.interfaces.FetchListener; -import awais.instagrabber.models.StoryModel; import awais.instagrabber.repositories.responses.UserInfo; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.CookieUtils; @@ -57,11 +49,6 @@ public class ProfilePicDialogFragment extends DialogFragment { private DialogProfilepicBinding binding; private String url; - private final FetchListener fetchListener = profileUrl -> { - url = profileUrl; - setupPhoto(); - }; - public ProfilePicDialogFragment(final String id, final String name, final String fallbackUrl) { this.id = id; this.name = name; @@ -133,7 +120,7 @@ public class ProfilePicDialogFragment extends DialogFragment { @Override public void onSuccess(final UserInfo result) { if (result != null) { - fetchListener.onResult(result.getHDProfilePicUrl()); + setupPhoto(result.getHDProfilePicUrl()); } } @@ -145,13 +132,12 @@ public class ProfilePicDialogFragment extends DialogFragment { } }); } - else new ProfilePictureFetcher(name, id, fetchListener, fallbackUrl, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + else setupPhoto(fallbackUrl); } - private void setupPhoto() { - if (TextUtils.isEmpty(url)) { - url = fallbackUrl; - } + private void setupPhoto(final String result) { + if (TextUtils.isEmpty(result)) url = fallbackUrl; + else url = result; final DraweeController controller = Fresco .newDraweeControllerBuilder() .setUri(url) diff --git a/app/src/main/java/awais/instagrabber/fragments/FavoritesFragment.java b/app/src/main/java/awais/instagrabber/fragments/FavoritesFragment.java index 34c81322..74b2cbb3 100644 --- a/app/src/main/java/awais/instagrabber/fragments/FavoritesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/FavoritesFragment.java @@ -25,8 +25,6 @@ import java.util.concurrent.CyclicBarrier; import awais.instagrabber.R; import awais.instagrabber.adapters.FavoritesAdapter; -import awais.instagrabber.asyncs.LocationFetcher; -import awais.instagrabber.asyncs.ProfileFetcher; import awais.instagrabber.databinding.FragmentFavoritesBinding; import awais.instagrabber.db.datasources.FavoriteDataSource; import awais.instagrabber.db.entities.Favorite; diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java index 51158a3b..03331704 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java @@ -43,7 +43,6 @@ public class AboutFragment extends BasePreferencesFragment { thirdPartyCategory.addPreference(getAutolinkPreference()); thirdPartyCategory.addPreference(getExoPlayerPreference()); thirdPartyCategory.addPreference(getFrescoPreference()); - thirdPartyCategory.addPreference(getJsoupPreference()); thirdPartyCategory.addPreference(getMDIPreference()); thirdPartyCategory.addPreference(getRetrofitPreference()); } @@ -114,22 +113,6 @@ public class AboutFragment extends BasePreferencesFragment { return preference; } - private Preference getJsoupPreference() { - final Context context = getContext(); - if (context == null) return null; - final Preference preference = new Preference(context); - preference.setTitle("jsoup"); - preference.setSummary("Copyright (c) 2009-2020 Jonathan Hedley. MIT License."); - preference.setIconSpaceReserved(false); - preference.setOnPreferenceClickListener(p -> { - final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("https://jsoup.org/")); - startActivity(intent); - return true; - }); - return preference; - } - private Preference getFrescoPreference() { final Context context = getContext(); if (context == null) return null; diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java index 24e935cf..64c49ed9 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java @@ -83,14 +83,13 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment { loggedInUsersPreferenceCategory.addPreference(getMarkStoriesSeenPreference()); loggedInUsersPreferenceCategory.addPreference(getMarkDMSeenPreference()); loggedInUsersPreferenceCategory.addPreference(getEnableActivityNotificationsPreference()); - } else { - final PreferenceCategory anonUsersPreferenceCategory = new PreferenceCategory(context); - screen.addPreference(anonUsersPreferenceCategory); - anonUsersPreferenceCategory.setIconSpaceReserved(false); - anonUsersPreferenceCategory.setTitle(R.string.anonymous_settings); - anonUsersPreferenceCategory.addPreference(getUseInstaDpPreference()); } - +// else { +// final PreferenceCategory anonUsersPreferenceCategory = new PreferenceCategory(context); +// screen.addPreference(anonUsersPreferenceCategory); +// anonUsersPreferenceCategory.setIconSpaceReserved(false); +// anonUsersPreferenceCategory.setTitle(R.string.anonymous_settings); +// } } private Preference getLanguagePreference() { @@ -260,16 +259,6 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment { return preference; } - private Preference getUseInstaDpPreference() { - final Context context = getContext(); - if (context == null) return null; - final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context); - preference.setKey(Constants.INSTADP); - preference.setTitle(R.string.instadp_settings); - preference.setIconSpaceReserved(false); - return preference; - } - private Preference getPostTimePreference() { final Context context = getContext(); if (context == null) return null; diff --git a/app/src/main/java/awais/instagrabber/utils/Constants.java b/app/src/main/java/awais/instagrabber/utils/Constants.java index e64041c2..85125516 100644 --- a/app/src/main/java/awais/instagrabber/utils/Constants.java +++ b/app/src/main/java/awais/instagrabber/utils/Constants.java @@ -21,7 +21,7 @@ public final class Constants { public static final String SWAP_DATE_TIME_FORMAT_ENABLED = "swap_date_time_enabled"; public static final String MARK_AS_SEEN = "mark_as_seen"; public static final String DM_MARK_AS_SEEN = "dm_mark_as_seen"; - public static final String INSTADP = "instadp"; + // deprecated: public static final String INSTADP = "instadp"; // deprecated: public static final String STORIESIG = "storiesig"; // deprecated: public static final String STORY_VIEWER = "story_viewer"; // deprecated: public static final String AMOLED_THEME = "amoled_theme"; diff --git a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java index d95a66ac..fa99a91f 100755 --- a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java +++ b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java @@ -24,7 +24,6 @@ import static awais.instagrabber.utils.Constants.DM_MARK_AS_SEEN; import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER; import static awais.instagrabber.utils.Constants.FOLDER_PATH; 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.MUTED_VIDEOS; import static awais.instagrabber.utils.Constants.PREF_DARK_THEME; @@ -127,7 +126,7 @@ public final class SettingsHelper { public @interface StringSettings {} @StringDef({DOWNLOAD_USER_FOLDER, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, - CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, INSTADP, CHECK_ACTIVITY, + CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, CHECK_ACTIVITY, CHECK_UPDATES, SWAP_DATE_TIME_FORMAT_ENABLED}) public @interface BooleanSettings {} From 147bc846961c4e5b73ed303d815df867498e9983 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sat, 2 Jan 2021 18:13:42 -0500 Subject: [PATCH 2/2] remove credits as they're messy Co-Authored-By: Ricardo <24703825+rickym7@users.noreply.github.com> --- app/src/main/res/values/arrays.xml | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 1f690941..3b5e8a70 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -3,25 +3,25 @@ System Default English - Français [Merci à @kernoeb et @PierreM0] - Español [Gracias a @sguinetti, @akrai y @retiolus] + Français + Español 简体中文 - Bahasa Indonesia [Terima kasih @Galang23] - Italiano [Grazie a @RAR_Ramar e GiorgioHerbie] - Deutsch [Danke an @peterge1998] - Polski [Podziękowania dla @Lego8486] - Türkçe [@faydin90 tarafından] - Português (Brasil) [Obrigado @wagnim, @RickyM7 e @cizordj] - پارسی [ با سپاس از farzadx@ ] - Македонски [Благодарност до @snajdovski] - Tiếng Việt [bởi Yato Fouze] - 繁體中文 [感謝 @Still34] - Català [Gràcies a @retiolus] - Русский [Спасибо @rikishi0071] + Bahasa Indonesia + Italiano + Deutsch + Polski + Türkçe + Português (Brasil) + پارسی + Македонски + Tiếng Việt + 繁體中文 + Català + Русский हिन्दी - Nederlands [Met dank aan Lesley Natrop] - Slovenčina [Vďaka @CrafterSvK] - 日本語 [協力 ysakamoto] + Nederlands + Slovenčina + 日本語 Auto / Follow System