From aa6dab07cbe971bbc038d460a5734506046de2af Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Fri, 11 Sep 2020 20:46:20 -0400 Subject: [PATCH] attempt to add a third-party storyviewer, plus logout without removing accounts --- .../fragments/StoryViewerFragment.java | 48 ++++----- .../fragments/main/ProfileFragment.java | 27 ++++- .../fragments/settings/AboutFragment.java | 30 ------ .../settings/MorePreferencesFragment.java | 56 +++++++---- .../settings/SettingsPreferencesFragment.java | 20 +++- .../models/enums/StoryViewerChoice.java | 20 ++++ .../thirdparty/AloRepository.java | 18 ++++ .../thirdparty/InstadpRepository.java | 15 +++ .../awais/instagrabber/utils/Constants.java | 5 +- .../awais/instagrabber/utils/CookieUtils.java | 6 +- .../instagrabber/utils/ExportImportUtils.java | 1 - .../instagrabber/utils/SettingsHelper.java | 24 ++--- .../instagrabber/webservices/AloService.java | 92 ++++++++++++++++++ .../webservices/FriendshipService.java | 29 +++--- .../main/res/drawable-anydpi/ic_delete.xml | 10 ++ .../main/res/drawable-anydpi/ic_logout.xml | 10 ++ app/src/main/res/drawable-hdpi/ic_delete.png | Bin 0 -> 199 bytes app/src/main/res/drawable-hdpi/ic_logout.png | Bin 0 -> 159 bytes app/src/main/res/drawable-mdpi/ic_delete.png | Bin 0 -> 135 bytes app/src/main/res/drawable-mdpi/ic_logout.png | Bin 0 -> 122 bytes app/src/main/res/drawable-xhdpi/ic_delete.png | Bin 0 -> 196 bytes app/src/main/res/drawable-xhdpi/ic_logout.png | Bin 0 -> 176 bytes .../main/res/drawable-xxhdpi/ic_delete.png | Bin 0 -> 236 bytes .../main/res/drawable-xxhdpi/ic_logout.png | Bin 0 -> 256 bytes app/src/main/res/values/arrays.xml | 6 ++ app/src/main/res/values/strings.xml | 4 + 26 files changed, 302 insertions(+), 119 deletions(-) create mode 100755 app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java create mode 100644 app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java create mode 100644 app/src/main/java/awais/instagrabber/repositories/thirdparty/InstadpRepository.java create mode 100644 app/src/main/java/awais/instagrabber/webservices/AloService.java create mode 100644 app/src/main/res/drawable-anydpi/ic_delete.xml create mode 100644 app/src/main/res/drawable-anydpi/ic_logout.xml create mode 100644 app/src/main/res/drawable-hdpi/ic_delete.png create mode 100644 app/src/main/res/drawable-hdpi/ic_logout.png create mode 100644 app/src/main/res/drawable-mdpi/ic_delete.png create mode 100644 app/src/main/res/drawable-mdpi/ic_logout.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_delete.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_logout.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_delete.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_logout.png diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 68b3eaa1..b8c0dbf2 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -75,9 +75,11 @@ import awais.instagrabber.models.FeedStoryModel; import awais.instagrabber.models.HighlightModel; import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.enums.MediaItemType; +import awais.instagrabber.models.enums.StoryViewerChoice; import awais.instagrabber.models.stickers.PollModel; import awais.instagrabber.models.stickers.QuestionModel; import awais.instagrabber.models.stickers.QuizModel; +import awais.instagrabber.webservices.AloService; import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.utils.Constants; @@ -109,6 +111,7 @@ 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; @@ -510,33 +513,34 @@ public class StoryViewerFragment extends Fragment { } storiesViewModel.getList().setValue(Collections.emptyList()); if (currentStoryMediaId == null) return; + final ServiceCallback storyCallback = new ServiceCallback>() { + @Override + public void onSuccess(final List storyModels) { + fetching = false; + if (storyModels == null || storyModels.isEmpty()) { + storiesViewModel.getList().setValue(Collections.emptyList()); + currentStory = null; + binding.storiesList.setVisibility(View.GONE); + return; + } + binding.storiesList.setVisibility(View.VISIBLE); + storiesViewModel.getList().setValue(storyModels); + currentStory = storyModels.get(0); + refreshStory(); + } + + @Override + public void onFailure(final Throwable t) { + Log.e(TAG, "Error", t); + } + }; storiesService.getUserStory(currentStoryMediaId, username, - !isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG), + !isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(), false, false, isHighlight, - new ServiceCallback>() { - @Override - public void onSuccess(final List storyModels) { - fetching = false; - if (storyModels == null || storyModels.isEmpty()) { - storiesViewModel.getList().setValue(Collections.emptyList()); - currentStory = null; - binding.storiesList.setVisibility(View.GONE); - return; - } - binding.storiesList.setVisibility(View.VISIBLE); - storiesViewModel.getList().setValue(storyModels); - currentStory = storyModels.get(0); - refreshStory(); - } - - @Override - public void onFailure(final Throwable t) { - Log.e(TAG, "Error", t); - } - }); + storyCallback); } private void refreshStory() { 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 465343ed..6b731a41 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java @@ -71,8 +71,10 @@ import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.PostItemType; +import awais.instagrabber.models.enums.StoryViewerChoice; import awais.instagrabber.repositories.responses.FriendshipRepoChangeRootResponse; import awais.instagrabber.repositories.responses.FriendshipRepoRestrictRootResponse; +import awais.instagrabber.webservices.AloService; import awais.instagrabber.webservices.FriendshipService; import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.utils.Constants; @@ -102,6 +104,7 @@ 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; @@ -208,6 +211,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe super.onCreate(savedInstanceState); fragmentActivity = (MainActivity) requireActivity(); friendshipService = FriendshipService.getInstance(); + aloService = AloService.getInstance(); setHasOptionsMenu(true); } @@ -354,12 +358,12 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe } binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); final String profileId = profileModel.getId(); - if (settingsHelper.getBoolean(Constants.STORIESIG) || isLoggedIn) { + if (settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue() || isLoggedIn) { new iStoryStatusFetcher(profileId, profileModel.getUsername(), false, false, - !isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG), + !isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(), false, result -> { storyModels = result; @@ -368,7 +372,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe } }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new HighlightsFetcher(profileId, - !isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG), + !isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(), result -> { if (result != null) { binding.highlightsList.setVisibility(View.VISIBLE); @@ -376,6 +380,23 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe } else binding.highlightsList.setVisibility(View.GONE); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } + else if (settingsHelper.getString(Constants.STORY_VIEWER).equals(StoryViewerChoice.ALOINSTAGRAM.getValue())) { + Log.d("austin_debug", "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); + } + }); + } if (isLoggedIn) { final String myId = CookieUtils.getUserIdFromCookie(cookie); 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 71388362..70fd86ba 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java @@ -55,9 +55,7 @@ public class AboutFragment extends BasePreferencesFragment { // alphabetical order!!! thirdPartyCategory.addPreference(getExoPlayerPreference()); thirdPartyCategory.addPreference(getFrescoPreference()); - thirdPartyCategory.addPreference(getGlidePreference()); thirdPartyCategory.addPreference(getJsoupPreference()); - thirdPartyCategory.addPreference(getPhotoViewPreference()); thirdPartyCategory.addPreference(getRetrofitPreference()); final PreferenceCategory licenseCategory = new PreferenceCategory(requireContext()); @@ -152,34 +150,6 @@ public class AboutFragment extends BasePreferencesFragment { return preference; } - private Preference getGlidePreference() { - final Preference preference = new Preference(requireContext()); - preference.setTitle("Glide"); - preference.setSummary("Copyright 2014 Google, Inc. All rights reserved. Custom license."); - preference.setIconSpaceReserved(false); - preference.setOnPreferenceClickListener(p -> { - final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("https://bumptech.github.io/glide/")); - startActivity(intent); - return true; - }); - return preference; - } - - private Preference getPhotoViewPreference() { - final Preference preference = new Preference(requireContext()); - preference.setTitle("PhotoView"); - preference.setSummary("Copyright 2018 Chris Banes. Apache Version 2.0."); - preference.setIconSpaceReserved(false); - preference.setOnPreferenceClickListener(p -> { - final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("https://github.com/chrisbanes/PhotoView")); - startActivity(intent); - return true; - }); - return preference; - } - private Preference getExoPlayerPreference() { final Preference preference = new Preference(requireContext()); preference.setTitle("ExoPlayer"); diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java index 0e76ff02..81391923 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java @@ -57,7 +57,6 @@ public class MorePreferencesFragment extends BasePreferencesFragment { final PreferenceCategory accountCategory = new PreferenceCategory(requireContext()); accountCategory.setTitle(R.string.account); - accountCategory.setSummary(R.string.account_hint); accountCategory.setIconSpaceReserved(false); screen.addPreference(accountCategory); // To re-login, user can just add the same account back from account switcher dialog @@ -70,41 +69,55 @@ public class MorePreferencesFragment extends BasePreferencesFragment { // return true; // })); if (isLoggedIn) { + accountCategory.setSummary(R.string.account_hint); accountCategory.addPreference(getAccountSwitcherPreference(cookie)); - accountCategory.addPreference(getPreference(R.string.logout, "Remove all accounts", -1, preference -> { + accountCategory.addPreference(getPreference(R.string.logout, R.string.logout_summary, R.drawable.ic_logout, preference -> { if (getContext() == null) return false; - new AlertDialog.Builder(getContext()) - .setTitle(R.string.logout) - .setMessage("This will remove all added accounts from the app!\n" - + "To remove just one account, long tap the account from the account switcher dialog.\n" - + "Do you want to continue?") - .setPositiveButton(R.string.yes, (dialog, which) -> { - CookieUtils.setupCookies("LOGOUT"); - shouldRecreate(); - Toast.makeText(requireContext(), R.string.logout_success, Toast.LENGTH_SHORT).show(); - settingsHelper.putString(Constants.COOKIE, ""); - }) - .setNegativeButton(R.string.cancel, null) - .show(); + CookieUtils.setupCookies("LOGOUT"); + shouldRecreate(); + Toast.makeText(requireContext(), R.string.logout_success, Toast.LENGTH_SHORT).show(); + settingsHelper.putString(Constants.COOKIE, ""); return true; })); } else { + if (Utils.dataBox.getAllCookies().size() > 0) { + accountCategory.addPreference(getAccountSwitcherPreference(null)); + } // Need to show something to trigger login activity accountCategory.addPreference(getPreference(R.string.add_account, R.drawable.ic_add, preference -> { startActivityForResult(new Intent(getContext(), Login.class), Constants.LOGIN_RESULT_CODE); return true; })); + if (Utils.dataBox.getAllCookies().size() > 0) { + accountCategory.addPreference(getPreference(R.string.remove_all_acc, null, R.drawable.ic_delete, preference -> { + if (getContext() == null) return false; + new AlertDialog.Builder(getContext()) + .setTitle(R.string.logout) + .setMessage(R.string.remove_all_acc_warning) + .setPositiveButton(R.string.yes, (dialog, which) -> { + CookieUtils.setupCookies("REMOVE"); + shouldRecreate(); + Toast.makeText(requireContext(), R.string.logout_success, Toast.LENGTH_SHORT).show(); + settingsHelper.putString(Constants.COOKIE, ""); + }) + .setNegativeButton(R.string.cancel, null) + .show(); + return true; + })); + } } final PreferenceCategory generalCategory = new PreferenceCategory(requireContext()); generalCategory.setTitle("General"); generalCategory.setIconSpaceReserved(false); screen.addPreference(generalCategory); - generalCategory.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> { - final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToNotificationsViewer(); - NavHostFragment.findNavController(this).navigate(navDirections); - return true; - })); + if (isLoggedIn) { + generalCategory.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> { + final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToNotificationsViewer(); + NavHostFragment.findNavController(this).navigate(navDirections); + return true; + })); + } generalCategory.addPreference(getPreference(R.string.action_settings, R.drawable.ic_outline_settings_24, preference -> { final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToSettingsPreferencesFragment(); NavHostFragment.findNavController(this).navigate(navDirections); @@ -129,7 +142,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment { screen.addPreference(versionPreference); final Preference reminderPreference = getPreference(R.string.reminder, R.string.reminder_summary, R.drawable.ic_warning, null); - reminderPreference.setEnabled(false); + reminderPreference.setSelectable(false); screen.addPreference(reminderPreference); } @@ -333,6 +346,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment { if (onClickListener != null) root.setOnClickListener(onClickListener); final PrefAccountSwitcherBinding binding = PrefAccountSwitcherBinding.bind(root); final String uid = CookieUtils.getUserIdFromCookie(cookie); + if (uid == null) return; final DataBox.CookieModel user = Utils.dataBox.getCookie(uid); if (user == null) return; binding.fullName.setText(user.getFullName()); 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 1515aaec..50d85e90 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java @@ -85,7 +85,7 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment { anonUsersPreferenceCategory.setIconSpaceReserved(false); anonUsersPreferenceCategory.setTitle(R.string.anonymous_settings); anonUsersPreferenceCategory.addPreference(getUseInstaDpPreference()); - anonUsersPreferenceCategory.addPreference(getUseStoriesIgPreference()); + anonUsersPreferenceCategory.addPreference(getStoryViewerPreference()); } } @@ -256,11 +256,21 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment { return preference; } - private Preference getUseStoriesIgPreference() { - final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(requireContext()); - preference.setKey(Constants.STORIESIG); - preference.setTitle(R.string.storiesig_settings); + @NonNull + private Preference getStoryViewerPreference() { + final ListPreference preference = new ListPreference(requireContext()); + 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; } diff --git a/app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java b/app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java new file mode 100755 index 00000000..38b91bc3 --- /dev/null +++ b/app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java @@ -0,0 +1,20 @@ +package awais.instagrabber.models.enums; + +import java.io.Serializable; + +public enum StoryViewerChoice implements Serializable { + NONE(0), + STORIESIG(1), + ALOINSTAGRAM(2), + INSTADP(3); + + private int value; + + StoryViewerChoice(int value) { + this.value = value; + } + + public String getValue() { + return String.valueOf(value); + } +} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java b/app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java new file mode 100644 index 00000000..18b29bc8 --- /dev/null +++ b/app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java @@ -0,0 +1,18 @@ +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 new file mode 100644 index 00000000..ef35cc71 --- /dev/null +++ b/app/src/main/java/awais/instagrabber/repositories/thirdparty/InstadpRepository.java @@ -0,0 +1,15 @@ +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 2c636acd..72d6cf61 100644 --- a/app/src/main/java/awais/instagrabber/utils/Constants.java +++ b/app/src/main/java/awais/instagrabber/utils/Constants.java @@ -12,7 +12,7 @@ public final class Constants { public static final String PREV_INSTALL_VERSION = "prevVersion"; // boolean prefs public static final String DOWNLOAD_USER_FOLDER = "download_user_folder"; - public static final String BOTTOM_TOOLBAR = "bottom_toolbar"; + // deprecated: public static final String BOTTOM_TOOLBAR = "bottom_toolbar"; public static final String FOLDER_SAVE_TO = "saved_to"; public static final String AUTOPLAY_VIDEOS = "autoplay_videos"; public static final String MUTED_VIDEOS = "muted_videos"; @@ -22,7 +22,8 @@ public final class Constants { 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"; - public static final String STORIESIG = "storiesig"; + // deprecated: public static final String STORIESIG = "storiesig"; + public static final String STORY_VIEWER = "story_viewer"; 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/CookieUtils.java b/app/src/main/java/awais/instagrabber/utils/CookieUtils.java index 92cf2004..e3e4f800 100644 --- a/app/src/main/java/awais/instagrabber/utils/CookieUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/CookieUtils.java @@ -23,11 +23,15 @@ public final class CookieUtils { if (cookieStore == null || TextUtils.isEmpty(cookieRaw)) { return; } - if (cookieRaw.equals("LOGOUT")) { + if (cookieRaw.equals("REMOVE")) { cookieStore.removeAll(); Utils.dataBox.deleteAllUserCookies(); return; } + else if (cookieRaw.equals("LOGOUT")) { + cookieStore.removeAll(); + return; + } try { final URI uri1 = new URI("https://instagram.com"); final URI uri2 = new URI("https://instagram.com/"); diff --git a/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java b/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java index 4a81ede9..750e3b80 100755 --- a/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java @@ -241,7 +241,6 @@ public final class ExportImportUtils { json.put(Constants.DOWNLOAD_USER_FOLDER, settingsHelper.getBoolean(Constants.DOWNLOAD_USER_FOLDER)); json.put(Constants.MUTED_VIDEOS, settingsHelper.getBoolean(Constants.MUTED_VIDEOS)); - json.put(Constants.BOTTOM_TOOLBAR, settingsHelper.getBoolean(Constants.BOTTOM_TOOLBAR)); json.put(Constants.AUTOPLAY_VIDEOS, settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS)); json.put(Constants.AUTOLOAD_POSTS, settingsHelper.getBoolean(Constants.AUTOLOAD_POSTS)); json.put(Constants.FOLDER_SAVE_TO, settingsHelper.getBoolean(Constants.FOLDER_SAVE_TO)); diff --git a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java index 7c397358..27476e09 100755 --- a/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java +++ b/app/src/main/java/awais/instagrabber/utils/SettingsHelper.java @@ -13,7 +13,6 @@ import static awais.instagrabber.utils.Constants.APP_LANGUAGE; import static awais.instagrabber.utils.Constants.APP_THEME; import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS; import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS; -import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR; import static awais.instagrabber.utils.Constants.CHECK_ACTIVITY; import static awais.instagrabber.utils.Constants.CHECK_UPDATES; import static awais.instagrabber.utils.Constants.COOKIE; @@ -33,7 +32,7 @@ import static awais.instagrabber.utils.Constants.MUTED_VIDEOS; 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.STORIESIG; +import static awais.instagrabber.utils.Constants.STORY_VIEWER; public final class SettingsHelper { private final SharedPreferences sharedPreferences; @@ -56,9 +55,8 @@ public final class SettingsHelper { } public boolean getBoolean(@BooleanSettings final String key) { - final boolean booleanDefault = getBooleanDefault(key); - if (sharedPreferences != null) return sharedPreferences.getBoolean(key, booleanDefault); - return booleanDefault; + if (sharedPreferences != null) return sharedPreferences.getBoolean(key, false); + return false; } @NonNull @@ -76,14 +74,6 @@ public final class SettingsHelper { return 0; } - private boolean getBooleanDefault(@BooleanSettings final String key) { - return BOTTOM_TOOLBAR.equals(key) || - AUTOPLAY_VIDEOS.equals(key) || - SHOW_QUICK_ACCESS_DIALOG.equals(key) || - MUTED_VIDEOS.equals(key) || - CHECK_UPDATES.equals(key); - } - public int getThemeCode(final boolean fromHelper) { int themeCode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; @@ -122,12 +112,12 @@ 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}) + DEVICE_UUID, SKIPPED_VERSION, DEFAULT_TAB, STORY_VIEWER}) public @interface StringSettings {} - @StringDef({DOWNLOAD_USER_FOLDER, BOTTOM_TOOLBAR, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, - AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, - INSTADP, STORIESIG, AMOLED_THEME, CHECK_ACTIVITY, CHECK_UPDATES}) + @StringDef({DOWNLOAD_USER_FOLDER, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, + AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, INSTADP, + AMOLED_THEME, CHECK_ACTIVITY, CHECK_UPDATES}) public @interface BooleanSettings {} @StringDef({PREV_INSTALL_VERSION}) diff --git a/app/src/main/java/awais/instagrabber/webservices/AloService.java b/app/src/main/java/awais/instagrabber/webservices/AloService.java new file mode 100644 index 00000000..2e243554 --- /dev/null +++ b/app/src/main/java/awais/instagrabber/webservices/AloService.java @@ -0,0 +1,92 @@ +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/java/awais/instagrabber/webservices/FriendshipService.java b/app/src/main/java/awais/instagrabber/webservices/FriendshipService.java index 205b601f..9874a855 100644 --- a/app/src/main/java/awais/instagrabber/webservices/FriendshipService.java +++ b/app/src/main/java/awais/instagrabber/webservices/FriendshipService.java @@ -39,35 +39,30 @@ public class FriendshipService extends BaseService { public void follow(final String userId, final String targetUserId, - final String crsfToken, + final String csrfToken, final ServiceCallback callback) { - change("create", userId, targetUserId, crsfToken, callback); + change("create", userId, targetUserId, csrfToken, callback); } public void unfollow(final String userId, final String targetUserId, - final String crsfToken, + final String csrfToken, final ServiceCallback callback) { - change("destroy", userId, targetUserId, crsfToken, callback); + change("destroy", userId, targetUserId, csrfToken, callback); } public void block(final String userId, final String targetUserId, - final String crsfToken, + final String csrfToken, final ServiceCallback callback) { - change("block", userId, targetUserId, crsfToken, callback); + change("block", userId, targetUserId, csrfToken, callback); } public void unblock(final String userId, final String targetUserId, - final String crsfToken, + final String csrfToken, final ServiceCallback callback) { - change("unblock", userId, targetUserId, crsfToken, callback); - } - - public void restrict(final String targetUserId, - final String csrfToken, - final ServiceCallback callback) { + change("unblock", userId, targetUserId, csrfToken, callback); } public void toggleRestrict(final String targetUserId, @@ -101,16 +96,16 @@ public class FriendshipService extends BaseService { public void approve(final String userId, final String targetUserId, - final String crsfToken, + final String csrfToken, final ServiceCallback callback) { - change("approve", userId, targetUserId, crsfToken, callback); + change("approve", userId, targetUserId, csrfToken, callback); } public void ignore(final String userId, final String targetUserId, - final String crsfToken, + final String csrfToken, final ServiceCallback callback) { - change("ignore", userId, targetUserId, crsfToken, callback); + change("ignore", userId, targetUserId, csrfToken, callback); } private void change(final String action, diff --git a/app/src/main/res/drawable-anydpi/ic_delete.xml b/app/src/main/res/drawable-anydpi/ic_delete.xml new file mode 100644 index 00000000..3c4030b0 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_delete.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_logout.xml b/app/src/main/res/drawable-anydpi/ic_logout.xml new file mode 100644 index 00000000..bab545a7 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_logout.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable-hdpi/ic_delete.png b/app/src/main/res/drawable-hdpi/ic_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..a37caccfee4a3aa96e345e562a58b3b84b731a6f GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbB`aE46Ln>}1CrGd^PH1RYxpL*^ znKNhd>*eI+oN@I(t}Nja9-=cTPL(pG`UCORfL_ literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-hdpi/ic_logout.png b/app/src/main/res/drawable-hdpi/ic_logout.png new file mode 100644 index 0000000000000000000000000000000000000000..12f49341c18436118ecbb726822d335d4ac91646 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbB(mY)pLn>~)y>7_Ypuppn$al5u z0Z$cs-jg@ED`$5nW;#v$KB>O&mypB~5v3@F(6#%fu_-Hk-~4igd72dmkAy*VLe2D< zvVz?QTJmZyT%Y)JyK&P09ak1OG%}g~JGp-5JV#3d7n2ptVT~uXZI@l-1KP;o>FVdQ I&MBb@02fO-IsgCw literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_delete.png b/app/src/main/res/drawable-mdpi/ic_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..04e26b3fb7955f1ab97e606698a2415f589dbba1 GIT binary patch literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjex5FlAr-fh6C_xtFeN7^>nW@= zG&G#q+4kGl*EjW~kw|x<%fo}ojIj)7W9_pJu3%j())VCrV{6bDakw$-_KA;;RvyZR hZOvEu!p^2JGgLNxzBXyWRY9Q144$rjF6*2UngA^REk^(V literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_logout.png b/app/src/main/res/drawable-mdpi/ic_logout.png new file mode 100644 index 0000000000000000000000000000000000000000..43335d7e02731d986ebb4096b5c55045d8c45fcc GIT binary patch literal 122 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gjj-D=#Ar-fh6C_xjxn|6o6~$P{ zbe6~5&~PT_(N`wMGDqZ0Ya}H7_~a_MGvr(rPvhbB?&dTh8fdnc3N4 fXC8HS%qnC0JoU89qA$ibL8f@R`njxgN@xNAgbYdB literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_logout.png b/app/src/main/res/drawable-xhdpi/ic_logout.png new file mode 100644 index 0000000000000000000000000000000000000000..46b2e904ee8465ea3a7c8adc9a20d724f2aa9494 GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUta!(h>kcwMxZ*1gkF%V!4G7oX(gM@4tePLfwnddkQk Z_~s2`Sf-U&XbI2>44$rjF6*2UngDuDK{x;a literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete.png b/app/src/main/res/drawable-xxhdpi/ic_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..75f41bb8d930ca14fc58515307f9a8cff453130b GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY1|&n@ZgvM!n>}3|Ln>~)y|$6}kOPmy#nqdc zgMZvHkUryZcH2Q&Q?Cxi_ulKySMG9=be^Q*X|<~(BCdFLv7P-K_q4bNb9ghI=iGO? z^`Ws`)}euck%`4)()?rl?n5~o0tygOyo?35T^-fpb8an_4M>aI&2Uw3ak6Y);OX0+ z*|x}ZhNNHTTU=dwbU$Zk`qtXDDxQ~)y=BOC$bg~kVo%?z z&|7R=vb#8xu10HCu;gd6xCb+dZFy4r!T+wDiRuLb70*d3o}t%E?^+(Sn0VsBmfYVJ z?;TY7nO8Ef2Qi+@{$40!USMQVd;k5z1C5&{{4SfATNqosbhvk@k(r%O#-iZC0T5%( z`n;$0mKOWjqKx?z*5B}Ikh#QN_pCkfM(eC*7EU1*j|mEnO>jm?&y=#Y-^?EfE&1|B t;)^8bIUb=oKAg`dl_@ELTvPg;rON2<_8+F3rUAXg;OXk;vd$@?2>_=LVCet= literal 0 HcmV?d00001 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 3d8dca86..d5a5ec87 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -38,6 +38,12 @@ 2 3 + + Disable + storiesig + Aloinstagram + Instadp + None \@ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 84a0286a..5bcfa9bb 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -53,6 +53,7 @@ Privacy Use Instadp for high definition profile pictures Use storiesig for stories and highlights from public users + Story viewer service Import/Export Language What to do? @@ -97,6 +98,9 @@ read moreā€¦ Login Logout + Browse Instagram anonymously + Remove all accounts + This will remove all added accounts from the app!\nTo remove just one account, long tap the account from the account switcher dialog.\nDo you want to continue? Send Debug Logs Date format Visit Project Page