1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 22:57:29 +00:00

remove instadp and jsoup

This commit is contained in:
Austin Huang 2021-01-02 13:27:36 -05:00
parent df6000e9c7
commit 26531198cb
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
8 changed files with 13 additions and 153 deletions

View File

@ -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'

View File

@ -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<Void, Void, String> {
private final FetchListener<String> fetchListener;
private final String userName, userId, picUrl;
private final boolean isHashtag;
public ProfilePictureFetcher(final String userName, final String userId, final FetchListener<String> 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);
}
}

View File

@ -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<String> 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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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";

View File

@ -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 {}