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 00000000..a37caccf Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_delete.png differ 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 00000000..12f49341 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_logout.png differ 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 00000000..04e26b3f Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_delete.png differ 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 00000000..43335d7e Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_logout.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_delete.png b/app/src/main/res/drawable-xhdpi/ic_delete.png new file mode 100644 index 00000000..fb6c1b9c Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete.png differ 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 00000000..46b2e904 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_logout.png differ 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 00000000..75f41bb8 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_logout.png b/app/src/main/res/drawable-xxhdpi/ic_logout.png new file mode 100644 index 00000000..665f4767 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_logout.png differ 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