removal of third-party story readers

This commit is contained in:
Austin Huang 2020-09-25 13:44:21 -04:00
parent 2f0e81d86f
commit 96a25f0d35
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
9 changed files with 2 additions and 174 deletions

View File

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

View File

@ -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<List<StoryModel>>() {
@Override
public void onSuccess(final List<StoryModel> 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);

View File

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

View File

@ -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<String> getUserStory(@Header("User-Agent") String userAgent,
@Field("storyonId") String id);
}

View File

@ -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<String> getUserStory(@Header("User-Agent") String userAgent,
@QueryMap(encoded = true) Map<String, String> variables);
}

View File

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

View File

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

View File

@ -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<List<StoryModel>> callback) {
final Call<String> userStoryCall = repository.getUserStory(Constants.A_USER_AGENT, id);
userStoryCall.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull final Call<String> call, @NonNull final Response<String> 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<StoryModel> 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<String> call, @NonNull final Throwable t) {
callback.onFailure(t);
}
});
}
}

View File

@ -40,11 +40,6 @@
<item>2</item>
<item>3</item>
</string-array>
<string-array name="anonymous_story_viewer">
<item>Disable</item>
<item>Aloinstagram</item>
<item>Instadp</item>
</string-array>
<string-array name="separator_presets">
<item>None</item>
<item>\@</item>