From 96a25f0d35bc4b3ef4eed62f0f658f2a14192bbd Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Fri, 25 Sep 2020 13:44:21 -0400 Subject: [PATCH] removal of third-party story readers --- .../fragments/StoryViewerFragment.java | 2 - .../fragments/main/ProfileFragment.java | 19 ---- .../settings/SettingsPreferencesFragment.java | 20 ---- .../thirdparty/AloRepository.java | 18 ---- .../thirdparty/InstadpRepository.java | 15 --- .../awais/instagrabber/utils/Constants.java | 2 +- .../instagrabber/utils/SettingsHelper.java | 3 +- .../instagrabber/webservices/AloService.java | 92 ------------------- app/src/main/res/values/arrays.xml | 5 - 9 files changed, 2 insertions(+), 174 deletions(-) delete mode 100644 app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java delete mode 100644 app/src/main/java/awais/instagrabber/repositories/thirdparty/InstadpRepository.java delete mode 100644 app/src/main/java/awais/instagrabber/webservices/AloService.java diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 29c50a80..8b5f506c 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -88,7 +88,6 @@ import awais.instagrabber.utils.Utils; import awais.instagrabber.viewmodels.FeedStoriesViewModel; import awais.instagrabber.viewmodels.HighlightsViewModel; import awais.instagrabber.viewmodels.StoriesViewModel; -import awais.instagrabber.webservices.AloService; import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.StoriesService; import awaisomereport.LogCollector; @@ -113,7 +112,6 @@ public class StoryViewerFragment extends Fragment { private SwipeEvent swipeEvent; private GestureDetectorCompat gestureDetector; private StoriesService storiesService; - private AloService aloService; private StoryModel currentStory; private int slidePos; private int lastSlidePos; diff --git a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java index 40746a8d..62672e13 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java @@ -85,7 +85,6 @@ import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.Utils; import awais.instagrabber.viewmodels.HighlightsViewModel; import awais.instagrabber.viewmodels.PostsViewModel; -import awais.instagrabber.webservices.AloService; import awais.instagrabber.webservices.FriendshipService; import awais.instagrabber.webservices.ServiceCallback; import awaisomereport.LogCollector; @@ -107,7 +106,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe private PostsAdapter postsAdapter; private ActionMode actionMode; private Handler usernameSettingHandler; - private AloService aloService; private FriendshipService friendshipService; private boolean shouldRefresh = true; private StoryModel[] storyModels; @@ -216,7 +214,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe super.onCreate(savedInstanceState); fragmentActivity = (MainActivity) requireActivity(); friendshipService = FriendshipService.getInstance(); - aloService = AloService.getInstance(); setHasOptionsMenu(true); } @@ -461,22 +458,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe highlightsViewModel.getList().postValue(result); } else binding.highlightsList.setVisibility(View.GONE); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } else if (settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.ALOINSTAGRAM.getValue())) { - // Log.d(TAG, "alo triggered"); - aloService.getUserStory(profileId, profileModel.getUsername(), false, new ServiceCallback>() { - @Override - public void onSuccess(final List result) { - if (result != null && result.size() > 0) { - storyModels = result.toArray(storyModels); - binding.mainProfileImage.setStoriesBorder(); - } - } - - @Override - public void onFailure(final Throwable t) { - Log.e(TAG, "Error on aloService", t); - } - }); } final String myId = CookieUtils.getUserIdFromCookie(cookie); 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 90b36445..d2b2ef87 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java @@ -89,7 +89,6 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment { anonUsersPreferenceCategory.setIconSpaceReserved(false); anonUsersPreferenceCategory.setTitle(R.string.anonymous_settings); anonUsersPreferenceCategory.addPreference(getUseInstaDpPreference()); - anonUsersPreferenceCategory.addPreference(getStoryViewerPreference()); } } @@ -253,25 +252,6 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment { return preference; } - private Preference getStoryViewerPreference() { - final Context context = getContext(); - if (context == null) return null; - final ListPreference preference = new ListPreference(context); - preference.setSummaryProvider(ListPreference.SimpleSummaryProvider.getInstance()); - final int length = getResources().getStringArray(R.array.anonymous_story_viewer).length; - final String[] values = new String[length]; - for (int i = 0; i < length; i++) { - values[i] = String.valueOf(i); - } - preference.setKey(Constants.STORY_VIEWER); - preference.setTitle(R.string.stories_viewer_settings); - preference.setDialogTitle(R.string.stories_viewer_settings); - preference.setEntries(R.array.anonymous_story_viewer); - preference.setIconSpaceReserved(false); - preference.setEntryValues(values); - return preference; - } - private Preference getPostTimePreference() { final Context context = getContext(); if (context == null) return null; diff --git a/app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java b/app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java deleted file mode 100644 index 18b29bc8..00000000 --- a/app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java +++ /dev/null @@ -1,18 +0,0 @@ -package awais.instagrabber.repositories.thirdparty; - -import java.util.Map; - -import retrofit2.Call; -import retrofit2.http.POST; -import retrofit2.http.Field; -import retrofit2.http.FormUrlEncoded; -import retrofit2.http.Header; -import retrofit2.http.Url; - -public interface AloRepository { - - @FormUrlEncoded - @POST("myfile/show.php") - Call getUserStory(@Header("User-Agent") String userAgent, - @Field("storyonId") String id); -} diff --git a/app/src/main/java/awais/instagrabber/repositories/thirdparty/InstadpRepository.java b/app/src/main/java/awais/instagrabber/repositories/thirdparty/InstadpRepository.java deleted file mode 100644 index ef35cc71..00000000 --- a/app/src/main/java/awais/instagrabber/repositories/thirdparty/InstadpRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package awais.instagrabber.repositories.thirdparty; - -import java.util.Map; - -import retrofit2.Call; -import retrofit2.http.Header; -import retrofit2.http.GET; -import retrofit2.http.QueryMap; - -public interface InstadpRepository { - - @GET("stories/{username}") - Call getUserStory(@Header("User-Agent") String userAgent, - @QueryMap(encoded = true) Map variables); -} diff --git a/app/src/main/java/awais/instagrabber/utils/Constants.java b/app/src/main/java/awais/instagrabber/utils/Constants.java index 4a599261..6fc40e6d 100644 --- a/app/src/main/java/awais/instagrabber/utils/Constants.java +++ b/app/src/main/java/awais/instagrabber/utils/Constants.java @@ -24,7 +24,7 @@ public final class Constants { public static final String DM_MARK_AS_SEEN = "dm_mark_as_seen"; public static final String INSTADP = "instadp"; // deprecated: public static final String STORIESIG = "storiesig"; - public static final String STORY_VIEWER = "story_viewer"; + // deprecated: public static final String STORY_VIEWER = "story_viewer"; // deprecated: public static final String AMOLED_THEME = "amoled_theme"; public static final String CHECK_ACTIVITY = "check_activity"; public static final String CHECK_UPDATES = "check_updates"; diff --git a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java index 34ad3102..5032cea3 100755 --- a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java +++ b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java @@ -33,7 +33,6 @@ import static awais.instagrabber.utils.Constants.PREF_LIGHT_THEME; import static awais.instagrabber.utils.Constants.PREV_INSTALL_VERSION; import static awais.instagrabber.utils.Constants.SHOW_QUICK_ACCESS_DIALOG; import static awais.instagrabber.utils.Constants.SKIPPED_VERSION; -import static awais.instagrabber.utils.Constants.STORY_VIEWER; import static awais.instagrabber.utils.Constants.SWAP_DATE_TIME_FORMAT_ENABLED; public final class SettingsHelper { @@ -114,7 +113,7 @@ public final class SettingsHelper { @StringDef( {APP_LANGUAGE, APP_THEME, COOKIE, FOLDER_PATH, DATE_TIME_FORMAT, DATE_TIME_SELECTION, CUSTOM_DATE_TIME_FORMAT, - DEVICE_UUID, SKIPPED_VERSION, DEFAULT_TAB, STORY_VIEWER, PREF_DARK_THEME, PREF_LIGHT_THEME}) + DEVICE_UUID, SKIPPED_VERSION, DEFAULT_TAB, PREF_DARK_THEME, PREF_LIGHT_THEME}) public @interface StringSettings {} @StringDef({DOWNLOAD_USER_FOLDER, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, diff --git a/app/src/main/java/awais/instagrabber/webservices/AloService.java b/app/src/main/java/awais/instagrabber/webservices/AloService.java deleted file mode 100644 index 2e243554..00000000 --- a/app/src/main/java/awais/instagrabber/webservices/AloService.java +++ /dev/null @@ -1,92 +0,0 @@ -package awais.instagrabber.webservices; - -import android.util.Log; - -import androidx.annotation.NonNull; - -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import awais.instagrabber.models.ProfileModel; -import awais.instagrabber.models.StoryModel; -import awais.instagrabber.models.enums.MediaItemType; -import awais.instagrabber.repositories.thirdparty.AloRepository; -import awais.instagrabber.utils.Constants; -import awais.instagrabber.utils.ResponseBodyUtils; -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; -import retrofit2.Retrofit; - -public class AloService extends BaseService { - private static final String TAG = "AloService"; - - private final AloRepository repository; - - private static AloService instance; - - private AloService() { - final Retrofit retrofit = getRetrofitBuilder() - .baseUrl("https://aloinstagram.com") - .build(); - repository = retrofit.create(AloRepository.class); - } - - public static AloService getInstance() { - if (instance == null) { - instance = new AloService(); - } - return instance; - } - - public void getUserStory(final String id, - final String username, - final boolean highlight, - final ServiceCallback> callback) { - final Call userStoryCall = repository.getUserStory(Constants.A_USER_AGENT, id); - userStoryCall.enqueue(new Callback() { - @Override - public void onResponse(@NonNull final Call call, @NonNull final Response response) { - final String body = response.body(); - if (body == null) { - Log.e(TAG, "body is null"); - return; - } - final Document data = Jsoup.parse(body); - final Elements media = data.select(".mySpan > a"); - - Log.d("austin_debug", id+ ": "+body); - - if (data != null && media != null) { - final int mediaLen = media.size(); - final List models = new ArrayList<>(); - for (Element story : media) { - - final StoryModel model = new StoryModel(null, - story.absUrl("href"), - story.selectFirst("video") != null ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE, - -1, // doesn't exist, to handle - username, - id, - false); - - models.add(model); - } - callback.onSuccess(models); - } - } - - @Override - public void onFailure(@NonNull final Call call, @NonNull final Throwable t) { - callback.onFailure(t); - } - }); - } -} diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 5e8ca0b2..3ddc20ba 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -40,11 +40,6 @@ 2 3 - - Disable - Aloinstagram - Instadp - None \@