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

attempt to add a third-party storyviewer, plus logout without removing accounts

This commit is contained in:
Austin Huang 2020-09-11 20:46:20 -04:00
parent 93e8e25186
commit aa6dab07cb
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
26 changed files with 302 additions and 119 deletions

View File

@ -75,9 +75,11 @@ import awais.instagrabber.models.FeedStoryModel;
import awais.instagrabber.models.HighlightModel; import awais.instagrabber.models.HighlightModel;
import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.StoryModel;
import awais.instagrabber.models.enums.MediaItemType; import awais.instagrabber.models.enums.MediaItemType;
import awais.instagrabber.models.enums.StoryViewerChoice;
import awais.instagrabber.models.stickers.PollModel; import awais.instagrabber.models.stickers.PollModel;
import awais.instagrabber.models.stickers.QuestionModel; import awais.instagrabber.models.stickers.QuestionModel;
import awais.instagrabber.models.stickers.QuizModel; import awais.instagrabber.models.stickers.QuizModel;
import awais.instagrabber.webservices.AloService;
import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.webservices.StoriesService; import awais.instagrabber.webservices.StoriesService;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
@ -109,6 +111,7 @@ public class StoryViewerFragment extends Fragment {
private SwipeEvent swipeEvent; private SwipeEvent swipeEvent;
private GestureDetectorCompat gestureDetector; private GestureDetectorCompat gestureDetector;
private StoriesService storiesService; private StoriesService storiesService;
private AloService aloService;
private StoryModel currentStory; private StoryModel currentStory;
private int slidePos; private int slidePos;
private int lastSlidePos; private int lastSlidePos;
@ -510,33 +513,34 @@ public class StoryViewerFragment extends Fragment {
} }
storiesViewModel.getList().setValue(Collections.emptyList()); storiesViewModel.getList().setValue(Collections.emptyList());
if (currentStoryMediaId == null) return; if (currentStoryMediaId == null) return;
final ServiceCallback storyCallback = new ServiceCallback<List<StoryModel>>() {
@Override
public void onSuccess(final List<StoryModel> 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, storiesService.getUserStory(currentStoryMediaId,
username, username,
!isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG), !isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(),
false, false,
false, false,
isHighlight, isHighlight,
new ServiceCallback<List<StoryModel>>() { storyCallback);
@Override
public void onSuccess(final List<StoryModel> 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);
}
});
} }
private void refreshStory() { private void refreshStory() {

View File

@ -71,8 +71,10 @@ import awais.instagrabber.models.ProfileModel;
import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.StoryModel;
import awais.instagrabber.models.enums.DownloadMethod; import awais.instagrabber.models.enums.DownloadMethod;
import awais.instagrabber.models.enums.PostItemType; import awais.instagrabber.models.enums.PostItemType;
import awais.instagrabber.models.enums.StoryViewerChoice;
import awais.instagrabber.repositories.responses.FriendshipRepoChangeRootResponse; import awais.instagrabber.repositories.responses.FriendshipRepoChangeRootResponse;
import awais.instagrabber.repositories.responses.FriendshipRepoRestrictRootResponse; import awais.instagrabber.repositories.responses.FriendshipRepoRestrictRootResponse;
import awais.instagrabber.webservices.AloService;
import awais.instagrabber.webservices.FriendshipService; import awais.instagrabber.webservices.FriendshipService;
import awais.instagrabber.webservices.ServiceCallback; import awais.instagrabber.webservices.ServiceCallback;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
@ -102,6 +104,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private PostsAdapter postsAdapter; private PostsAdapter postsAdapter;
private ActionMode actionMode; private ActionMode actionMode;
private Handler usernameSettingHandler; private Handler usernameSettingHandler;
private AloService aloService;
private FriendshipService friendshipService; private FriendshipService friendshipService;
private boolean shouldRefresh = true; private boolean shouldRefresh = true;
private StoryModel[] storyModels; private StoryModel[] storyModels;
@ -208,6 +211,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
fragmentActivity = (MainActivity) requireActivity(); fragmentActivity = (MainActivity) requireActivity();
friendshipService = FriendshipService.getInstance(); friendshipService = FriendshipService.getInstance();
aloService = AloService.getInstance();
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@ -354,12 +358,12 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE); binding.isVerified.setVisibility(profileModel.isVerified() ? View.VISIBLE : View.GONE);
final String profileId = profileModel.getId(); final String profileId = profileModel.getId();
if (settingsHelper.getBoolean(Constants.STORIESIG) || isLoggedIn) { if (settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue() || isLoggedIn) {
new iStoryStatusFetcher(profileId, new iStoryStatusFetcher(profileId,
profileModel.getUsername(), profileModel.getUsername(),
false, false,
false, false,
!isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG), !isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(),
false, false,
result -> { result -> {
storyModels = result; storyModels = result;
@ -368,7 +372,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
new HighlightsFetcher(profileId, new HighlightsFetcher(profileId,
!isLoggedIn && settingsHelper.getBoolean(Constants.STORIESIG), !isLoggedIn && settingsHelper.getString(Constants.STORY_VIEWER) == StoryViewerChoice.STORIESIG.getValue(),
result -> { result -> {
if (result != null) { if (result != null) {
binding.highlightsList.setVisibility(View.VISIBLE); binding.highlightsList.setVisibility(View.VISIBLE);
@ -376,6 +380,23 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} else binding.highlightsList.setVisibility(View.GONE); } else binding.highlightsList.setVisibility(View.GONE);
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).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<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);
}
});
}
if (isLoggedIn) { if (isLoggedIn) {
final String myId = CookieUtils.getUserIdFromCookie(cookie); final String myId = CookieUtils.getUserIdFromCookie(cookie);

View File

@ -55,9 +55,7 @@ public class AboutFragment extends BasePreferencesFragment {
// alphabetical order!!! // alphabetical order!!!
thirdPartyCategory.addPreference(getExoPlayerPreference()); thirdPartyCategory.addPreference(getExoPlayerPreference());
thirdPartyCategory.addPreference(getFrescoPreference()); thirdPartyCategory.addPreference(getFrescoPreference());
thirdPartyCategory.addPreference(getGlidePreference());
thirdPartyCategory.addPreference(getJsoupPreference()); thirdPartyCategory.addPreference(getJsoupPreference());
thirdPartyCategory.addPreference(getPhotoViewPreference());
thirdPartyCategory.addPreference(getRetrofitPreference()); thirdPartyCategory.addPreference(getRetrofitPreference());
final PreferenceCategory licenseCategory = new PreferenceCategory(requireContext()); final PreferenceCategory licenseCategory = new PreferenceCategory(requireContext());
@ -152,34 +150,6 @@ public class AboutFragment extends BasePreferencesFragment {
return preference; 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() { private Preference getExoPlayerPreference() {
final Preference preference = new Preference(requireContext()); final Preference preference = new Preference(requireContext());
preference.setTitle("ExoPlayer"); preference.setTitle("ExoPlayer");

View File

@ -57,7 +57,6 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
final PreferenceCategory accountCategory = new PreferenceCategory(requireContext()); final PreferenceCategory accountCategory = new PreferenceCategory(requireContext());
accountCategory.setTitle(R.string.account); accountCategory.setTitle(R.string.account);
accountCategory.setSummary(R.string.account_hint);
accountCategory.setIconSpaceReserved(false); accountCategory.setIconSpaceReserved(false);
screen.addPreference(accountCategory); screen.addPreference(accountCategory);
// To re-login, user can just add the same account back from account switcher dialog // 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; // return true;
// })); // }));
if (isLoggedIn) { if (isLoggedIn) {
accountCategory.setSummary(R.string.account_hint);
accountCategory.addPreference(getAccountSwitcherPreference(cookie)); 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; if (getContext() == null) return false;
new AlertDialog.Builder(getContext()) CookieUtils.setupCookies("LOGOUT");
.setTitle(R.string.logout) shouldRecreate();
.setMessage("This will remove all added accounts from the app!\n" Toast.makeText(requireContext(), R.string.logout_success, Toast.LENGTH_SHORT).show();
+ "To remove just one account, long tap the account from the account switcher dialog.\n" settingsHelper.putString(Constants.COOKIE, "");
+ "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();
return true; return true;
})); }));
} else { } else {
if (Utils.dataBox.getAllCookies().size() > 0) {
accountCategory.addPreference(getAccountSwitcherPreference(null));
}
// Need to show something to trigger login activity // Need to show something to trigger login activity
accountCategory.addPreference(getPreference(R.string.add_account, R.drawable.ic_add, preference -> { accountCategory.addPreference(getPreference(R.string.add_account, R.drawable.ic_add, preference -> {
startActivityForResult(new Intent(getContext(), Login.class), Constants.LOGIN_RESULT_CODE); startActivityForResult(new Intent(getContext(), Login.class), Constants.LOGIN_RESULT_CODE);
return true; 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()); final PreferenceCategory generalCategory = new PreferenceCategory(requireContext());
generalCategory.setTitle("General"); generalCategory.setTitle("General");
generalCategory.setIconSpaceReserved(false); generalCategory.setIconSpaceReserved(false);
screen.addPreference(generalCategory); screen.addPreference(generalCategory);
generalCategory.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> { if (isLoggedIn) {
final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToNotificationsViewer(); generalCategory.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> {
NavHostFragment.findNavController(this).navigate(navDirections); final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToNotificationsViewer();
return true; NavHostFragment.findNavController(this).navigate(navDirections);
})); return true;
}));
}
generalCategory.addPreference(getPreference(R.string.action_settings, R.drawable.ic_outline_settings_24, preference -> { generalCategory.addPreference(getPreference(R.string.action_settings, R.drawable.ic_outline_settings_24, preference -> {
final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToSettingsPreferencesFragment(); final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToSettingsPreferencesFragment();
NavHostFragment.findNavController(this).navigate(navDirections); NavHostFragment.findNavController(this).navigate(navDirections);
@ -129,7 +142,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
screen.addPreference(versionPreference); screen.addPreference(versionPreference);
final Preference reminderPreference = getPreference(R.string.reminder, R.string.reminder_summary, R.drawable.ic_warning, null); 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); screen.addPreference(reminderPreference);
} }
@ -333,6 +346,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
if (onClickListener != null) root.setOnClickListener(onClickListener); if (onClickListener != null) root.setOnClickListener(onClickListener);
final PrefAccountSwitcherBinding binding = PrefAccountSwitcherBinding.bind(root); final PrefAccountSwitcherBinding binding = PrefAccountSwitcherBinding.bind(root);
final String uid = CookieUtils.getUserIdFromCookie(cookie); final String uid = CookieUtils.getUserIdFromCookie(cookie);
if (uid == null) return;
final DataBox.CookieModel user = Utils.dataBox.getCookie(uid); final DataBox.CookieModel user = Utils.dataBox.getCookie(uid);
if (user == null) return; if (user == null) return;
binding.fullName.setText(user.getFullName()); binding.fullName.setText(user.getFullName());

View File

@ -85,7 +85,7 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment {
anonUsersPreferenceCategory.setIconSpaceReserved(false); anonUsersPreferenceCategory.setIconSpaceReserved(false);
anonUsersPreferenceCategory.setTitle(R.string.anonymous_settings); anonUsersPreferenceCategory.setTitle(R.string.anonymous_settings);
anonUsersPreferenceCategory.addPreference(getUseInstaDpPreference()); anonUsersPreferenceCategory.addPreference(getUseInstaDpPreference());
anonUsersPreferenceCategory.addPreference(getUseStoriesIgPreference()); anonUsersPreferenceCategory.addPreference(getStoryViewerPreference());
} }
} }
@ -256,11 +256,21 @@ public class SettingsPreferencesFragment extends BasePreferencesFragment {
return preference; return preference;
} }
private Preference getUseStoriesIgPreference() { @NonNull
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(requireContext()); private Preference getStoryViewerPreference() {
preference.setKey(Constants.STORIESIG); final ListPreference preference = new ListPreference(requireContext());
preference.setTitle(R.string.storiesig_settings); 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.setIconSpaceReserved(false);
preference.setEntryValues(values);
return preference; return preference;
} }

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ public final class Constants {
public static final String PREV_INSTALL_VERSION = "prevVersion"; public static final String PREV_INSTALL_VERSION = "prevVersion";
// boolean prefs // boolean prefs
public static final String DOWNLOAD_USER_FOLDER = "download_user_folder"; 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 FOLDER_SAVE_TO = "saved_to";
public static final String AUTOPLAY_VIDEOS = "autoplay_videos"; public static final String AUTOPLAY_VIDEOS = "autoplay_videos";
public static final String MUTED_VIDEOS = "muted_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 MARK_AS_SEEN = "mark_as_seen";
public static final String DM_MARK_AS_SEEN = "dm_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 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 AMOLED_THEME = "amoled_theme";
public static final String CHECK_ACTIVITY = "check_activity"; public static final String CHECK_ACTIVITY = "check_activity";
public static final String CHECK_UPDATES = "check_updates"; public static final String CHECK_UPDATES = "check_updates";

View File

@ -23,11 +23,15 @@ public final class CookieUtils {
if (cookieStore == null || TextUtils.isEmpty(cookieRaw)) { if (cookieStore == null || TextUtils.isEmpty(cookieRaw)) {
return; return;
} }
if (cookieRaw.equals("LOGOUT")) { if (cookieRaw.equals("REMOVE")) {
cookieStore.removeAll(); cookieStore.removeAll();
Utils.dataBox.deleteAllUserCookies(); Utils.dataBox.deleteAllUserCookies();
return; return;
} }
else if (cookieRaw.equals("LOGOUT")) {
cookieStore.removeAll();
return;
}
try { try {
final URI uri1 = new URI("https://instagram.com"); final URI uri1 = new URI("https://instagram.com");
final URI uri2 = new URI("https://instagram.com/"); final URI uri2 = new URI("https://instagram.com/");

View File

@ -241,7 +241,6 @@ public final class ExportImportUtils {
json.put(Constants.DOWNLOAD_USER_FOLDER, settingsHelper.getBoolean(Constants.DOWNLOAD_USER_FOLDER)); 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.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.AUTOPLAY_VIDEOS, settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS));
json.put(Constants.AUTOLOAD_POSTS, settingsHelper.getBoolean(Constants.AUTOLOAD_POSTS)); json.put(Constants.AUTOLOAD_POSTS, settingsHelper.getBoolean(Constants.AUTOLOAD_POSTS));
json.put(Constants.FOLDER_SAVE_TO, settingsHelper.getBoolean(Constants.FOLDER_SAVE_TO)); json.put(Constants.FOLDER_SAVE_TO, settingsHelper.getBoolean(Constants.FOLDER_SAVE_TO));

View File

@ -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.APP_THEME;
import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS; import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS;
import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS; 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_ACTIVITY;
import static awais.instagrabber.utils.Constants.CHECK_UPDATES; import static awais.instagrabber.utils.Constants.CHECK_UPDATES;
import static awais.instagrabber.utils.Constants.COOKIE; 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.PREV_INSTALL_VERSION;
import static awais.instagrabber.utils.Constants.SHOW_QUICK_ACCESS_DIALOG; import static awais.instagrabber.utils.Constants.SHOW_QUICK_ACCESS_DIALOG;
import static awais.instagrabber.utils.Constants.SKIPPED_VERSION; 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 { public final class SettingsHelper {
private final SharedPreferences sharedPreferences; private final SharedPreferences sharedPreferences;
@ -56,9 +55,8 @@ public final class SettingsHelper {
} }
public boolean getBoolean(@BooleanSettings final String key) { public boolean getBoolean(@BooleanSettings final String key) {
final boolean booleanDefault = getBooleanDefault(key); if (sharedPreferences != null) return sharedPreferences.getBoolean(key, false);
if (sharedPreferences != null) return sharedPreferences.getBoolean(key, booleanDefault); return false;
return booleanDefault;
} }
@NonNull @NonNull
@ -76,14 +74,6 @@ public final class SettingsHelper {
return 0; 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) { public int getThemeCode(final boolean fromHelper) {
int themeCode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM; int themeCode = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
@ -122,12 +112,12 @@ public final class SettingsHelper {
@StringDef( @StringDef(
{APP_LANGUAGE, APP_THEME, COOKIE, FOLDER_PATH, DATE_TIME_FORMAT, DATE_TIME_SELECTION, CUSTOM_DATE_TIME_FORMAT, {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 {} public @interface StringSettings {}
@StringDef({DOWNLOAD_USER_FOLDER, BOTTOM_TOOLBAR, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS, @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, AUTOLOAD_POSTS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, INSTADP,
INSTADP, STORIESIG, AMOLED_THEME, CHECK_ACTIVITY, CHECK_UPDATES}) AMOLED_THEME, CHECK_ACTIVITY, CHECK_UPDATES})
public @interface BooleanSettings {} public @interface BooleanSettings {}
@StringDef({PREV_INSTALL_VERSION}) @StringDef({PREV_INSTALL_VERSION})

View File

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

@ -39,35 +39,30 @@ public class FriendshipService extends BaseService {
public void follow(final String userId, public void follow(final String userId,
final String targetUserId, final String targetUserId,
final String crsfToken, final String csrfToken,
final ServiceCallback<FriendshipRepoChangeRootResponse> callback) { final ServiceCallback<FriendshipRepoChangeRootResponse> callback) {
change("create", userId, targetUserId, crsfToken, callback); change("create", userId, targetUserId, csrfToken, callback);
} }
public void unfollow(final String userId, public void unfollow(final String userId,
final String targetUserId, final String targetUserId,
final String crsfToken, final String csrfToken,
final ServiceCallback<FriendshipRepoChangeRootResponse> callback) { final ServiceCallback<FriendshipRepoChangeRootResponse> callback) {
change("destroy", userId, targetUserId, crsfToken, callback); change("destroy", userId, targetUserId, csrfToken, callback);
} }
public void block(final String userId, public void block(final String userId,
final String targetUserId, final String targetUserId,
final String crsfToken, final String csrfToken,
final ServiceCallback<FriendshipRepoChangeRootResponse> callback) { final ServiceCallback<FriendshipRepoChangeRootResponse> callback) {
change("block", userId, targetUserId, crsfToken, callback); change("block", userId, targetUserId, csrfToken, callback);
} }
public void unblock(final String userId, public void unblock(final String userId,
final String targetUserId, final String targetUserId,
final String crsfToken, final String csrfToken,
final ServiceCallback<FriendshipRepoChangeRootResponse> callback) { final ServiceCallback<FriendshipRepoChangeRootResponse> callback) {
change("unblock", userId, targetUserId, crsfToken, callback); change("unblock", userId, targetUserId, csrfToken, callback);
}
public void restrict(final String targetUserId,
final String csrfToken,
final ServiceCallback<FriendshipRepoRestrictRootResponse> callback) {
} }
public void toggleRestrict(final String targetUserId, public void toggleRestrict(final String targetUserId,
@ -101,16 +96,16 @@ public class FriendshipService extends BaseService {
public void approve(final String userId, public void approve(final String userId,
final String targetUserId, final String targetUserId,
final String crsfToken, final String csrfToken,
final ServiceCallback<FriendshipRepoChangeRootResponse> callback) { final ServiceCallback<FriendshipRepoChangeRootResponse> callback) {
change("approve", userId, targetUserId, crsfToken, callback); change("approve", userId, targetUserId, csrfToken, callback);
} }
public void ignore(final String userId, public void ignore(final String userId,
final String targetUserId, final String targetUserId,
final String crsfToken, final String csrfToken,
final ServiceCallback<FriendshipRepoChangeRootResponse> callback) { final ServiceCallback<FriendshipRepoChangeRootResponse> callback) {
change("ignore", userId, targetUserId, crsfToken, callback); change("ignore", userId, targetUserId, csrfToken, callback);
} }
private void change(final String action, private void change(final String action,

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

View File

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

View File

@ -53,6 +53,7 @@
<string name="privacy_warning">Privacy</string> <string name="privacy_warning">Privacy</string>
<string name="instadp_settings">Use Instadp for high definition profile pictures</string> <string name="instadp_settings">Use Instadp for high definition profile pictures</string>
<string name="storiesig_settings">Use storiesig for stories and highlights from public users</string> <string name="storiesig_settings">Use storiesig for stories and highlights from public users</string>
<string name="stories_viewer_settings">Story viewer service</string>
<string name="import_export">Import/Export</string> <string name="import_export">Import/Export</string>
<string name="select_language">Language</string> <string name="select_language">Language</string>
<string name="what_to_do_dialog">What to do?</string> <string name="what_to_do_dialog">What to do?</string>
@ -97,6 +98,9 @@
<string name="read_more">read more…</string> <string name="read_more">read more…</string>
<string name="login">Login</string> <string name="login">Login</string>
<string name="logout">Logout</string> <string name="logout">Logout</string>
<string name="logout_summary">Browse Instagram anonymously</string>
<string name="remove_all_acc">Remove all accounts</string>
<string name="remove_all_acc_warning">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?</string>
<string name="send_logs">Send Debug Logs</string> <string name="send_logs">Send Debug Logs</string>
<string name="time_settings">Date format</string> <string name="time_settings">Date format</string>
<string name="project_link">Visit Project Page</string> <string name="project_link">Visit Project Page</string>