migrate preference keys
This commit is contained in:
parent
85ac7478eb
commit
ba0d51d0b6
@ -13,6 +13,7 @@ import java.net.CookieHandler;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.LocaleUtils;
|
||||
import awais.instagrabber.utils.SettingsHelper;
|
||||
@ -82,9 +83,9 @@ public final class InstaGrabberApplication extends Application {
|
||||
|
||||
if (datetimeParser == null)
|
||||
datetimeParser = new SimpleDateFormat(
|
||||
settingsHelper.getBoolean(Constants.CUSTOM_DATE_TIME_FORMAT_ENABLED) ?
|
||||
settingsHelper.getString(Constants.CUSTOM_DATE_TIME_FORMAT) :
|
||||
settingsHelper.getString(Constants.DATE_TIME_FORMAT), LocaleUtils.getCurrentLocale());
|
||||
settingsHelper.getBoolean(PreferenceKeys.CUSTOM_DATE_TIME_FORMAT_ENABLED) ?
|
||||
settingsHelper.getString(PreferenceKeys.CUSTOM_DATE_TIME_FORMAT) :
|
||||
settingsHelper.getString(PreferenceKeys.DATE_TIME_FORMAT), LocaleUtils.getCurrentLocale());
|
||||
|
||||
if (TextUtils.isEmpty(settingsHelper.getString(Constants.DEVICE_UUID))) {
|
||||
settingsHelper.putString(Constants.DEVICE_UUID, UUID.randomUUID().toString());
|
||||
|
@ -141,7 +141,7 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
||||
instance = this;
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setupCookie();
|
||||
if (settingsHelper.getBoolean(Constants.FLAG_SECURE)) {
|
||||
if (settingsHelper.getBoolean(PreferenceKeys.FLAG_SECURE)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
||||
}
|
||||
setContentView(binding.getRoot());
|
||||
@ -166,14 +166,14 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
||||
setupBottomNavigationBar(true);
|
||||
}
|
||||
if (!BuildConfig.isPre) {
|
||||
final boolean checkUpdates = settingsHelper.getBoolean(Constants.CHECK_UPDATES);
|
||||
final boolean checkUpdates = settingsHelper.getBoolean(PreferenceKeys.CHECK_UPDATES);
|
||||
if (checkUpdates) FlavorTown.updateCheck(this);
|
||||
}
|
||||
FlavorTown.changelogCheck(this);
|
||||
new ViewModelProvider(this).get(AppStateViewModel.class); // Just initiate the App state here
|
||||
final Intent intent = getIntent();
|
||||
handleIntent(intent);
|
||||
if (isLoggedIn && settingsHelper.getBoolean(Constants.CHECK_ACTIVITY)) {
|
||||
if (isLoggedIn && settingsHelper.getBoolean(PreferenceKeys.CHECK_ACTIVITY)) {
|
||||
bindActivityCheckerService();
|
||||
}
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
|
@ -15,9 +15,9 @@ import awais.instagrabber.adapters.SliderItemsAdapter;
|
||||
import awais.instagrabber.customviews.VideoPlayerCallbackAdapter;
|
||||
import awais.instagrabber.customviews.VideoPlayerViewHelper;
|
||||
import awais.instagrabber.databinding.LayoutVideoPlayerWithThumbnailBinding;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.VideoVersion;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.NumberUtils;
|
||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
@ -55,7 +55,7 @@ public class SliderVideoViewHolder extends SliderItemViewHolder {
|
||||
public void bind(@NonNull final Media media,
|
||||
final int position,
|
||||
final SliderItemsAdapter.SliderCallback sliderCallback) {
|
||||
final float vol = settingsHelper.getBoolean(Constants.MUTED_VIDEOS) ? 0f : 1f;
|
||||
final float vol = settingsHelper.getBoolean(PreferenceKeys.MUTED_VIDEOS) ? 0f : 1f;
|
||||
final VideoPlayerViewHelper.VideoPlayerCallback videoPlayerCallback = new VideoPlayerCallbackAdapter() {
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ import java.util.HashSet;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.KeywordsFilterAdapter;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.utils.SettingsHelper;
|
||||
|
||||
public class KeywordsFilterDialogViewHolder extends RecyclerView.ViewHolder {
|
||||
@ -34,7 +34,7 @@ public class KeywordsFilterDialogViewHolder extends RecyclerView.ViewHolder {
|
||||
final String s = items.get(position);
|
||||
SettingsHelper settingsHelper = new SettingsHelper(context);
|
||||
items.remove(position);
|
||||
settingsHelper.putStringSet(Constants.KEYWORD_FILTERS, new HashSet<>(items));
|
||||
settingsHelper.putStringSet(PreferenceKeys.KEYWORD_FILTERS, new HashSet<>(items));
|
||||
adapter.notifyDataSetChanged();
|
||||
final String message = context.getString(R.string.removed_keywords, s);
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
|
@ -18,9 +18,9 @@ import awais.instagrabber.adapters.FeedAdapterV2;
|
||||
import awais.instagrabber.customviews.VideoPlayerCallbackAdapter;
|
||||
import awais.instagrabber.customviews.VideoPlayerViewHelper;
|
||||
import awais.instagrabber.databinding.ItemFeedVideoBinding;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.VideoVersion;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.NumberUtils;
|
||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
@ -65,7 +65,7 @@ public class FeedVideoViewHolder extends FeedItemViewHolder {
|
||||
// Log.d(TAG, "Binding post: " + feedModel.getPostId());
|
||||
this.media = media;
|
||||
binding.itemFeedBottom.tvVideoViews.setText(String.valueOf(media.getViewCount()));
|
||||
final float vol = settingsHelper.getBoolean(Constants.MUTED_VIDEOS) ? 0f : 1f;
|
||||
final float vol = settingsHelper.getBoolean(PreferenceKeys.MUTED_VIDEOS) ? 0f : 1f;
|
||||
final VideoPlayerViewHelper.VideoPlayerCallback videoPlayerCallback = new VideoPlayerCallbackAdapter() {
|
||||
|
||||
@Override
|
||||
|
@ -33,10 +33,10 @@ import awais.instagrabber.adapters.FeedAdapterV2;
|
||||
import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration;
|
||||
import awais.instagrabber.customviews.helpers.PostFetcher;
|
||||
import awais.instagrabber.customviews.helpers.RecyclerLazyLoaderAtEdge;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.models.PostsLayoutPreferences;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.KeywordsFilterUtils;
|
||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
@ -81,8 +81,8 @@ public class PostsRecyclerView extends RecyclerView {
|
||||
}
|
||||
final List<Media> models = mediaViewModel.getList().getValue();
|
||||
final List<Media> modelsCopy = models == null ? new ArrayList<>() : new ArrayList<>(models);
|
||||
if (settingsHelper.getBoolean(Constants.TOGGLE_KEYWORD_FILTER)) {
|
||||
final ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(Constants.KEYWORD_FILTERS));
|
||||
if (settingsHelper.getBoolean(PreferenceKeys.TOGGLE_KEYWORD_FILTER)) {
|
||||
final ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(PreferenceKeys.KEYWORD_FILTERS));
|
||||
modelsCopy.addAll(new KeywordsFilterUtils(items).filter(result));
|
||||
} else {
|
||||
modelsCopy.addAll(result);
|
||||
|
@ -29,7 +29,7 @@ import awais.instagrabber.utils.ExportImportUtils;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_PATH;
|
||||
import static awais.instagrabber.utils.DownloadUtils.PERMS;
|
||||
|
||||
public class CreateBackupDialogFragment extends DialogFragment {
|
||||
|
@ -22,7 +22,7 @@ import java.util.HashSet;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.adapters.KeywordsFilterAdapter;
|
||||
import awais.instagrabber.databinding.DialogKeywordsFilterBinding;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.utils.SettingsHelper;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
@ -54,7 +54,7 @@ public final class KeywordsFilterDialog extends DialogFragment {
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
final SettingsHelper settingsHelper = new SettingsHelper(context);
|
||||
final ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(Constants.KEYWORD_FILTERS));
|
||||
final ArrayList<String> items = new ArrayList<>(settingsHelper.getStringSet(PreferenceKeys.KEYWORD_FILTERS));
|
||||
final KeywordsFilterAdapter adapter = new KeywordsFilterAdapter(context, items);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
@ -68,7 +68,7 @@ public final class KeywordsFilterDialog extends DialogFragment {
|
||||
return;
|
||||
}
|
||||
items.add(s.toLowerCase());
|
||||
settingsHelper.putStringSet(Constants.KEYWORD_FILTERS, new HashSet<>(items));
|
||||
settingsHelper.putStringSet(PreferenceKeys.KEYWORD_FILTERS, new HashSet<>(items));
|
||||
adapter.notifyItemInserted(items.size());
|
||||
final String message = context.getString(R.string.added_keywords, s);
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
|
@ -28,7 +28,7 @@ import awais.instagrabber.utils.PasswordUtils.IncorrectPasswordException;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_PATH;
|
||||
import static awais.instagrabber.utils.DownloadUtils.PERMS;
|
||||
|
||||
public class RestoreBackupDialogFragment extends DialogFragment {
|
||||
|
@ -82,6 +82,7 @@ import awais.instagrabber.databinding.DialogPostViewBinding;
|
||||
import awais.instagrabber.databinding.LayoutPostViewBottomBinding;
|
||||
import awais.instagrabber.databinding.LayoutVideoPlayerWithThumbnailBinding;
|
||||
import awais.instagrabber.dialogs.EditTextDialogFragment;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.models.Resource;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.repositories.responses.Caption;
|
||||
@ -89,7 +90,6 @@ import awais.instagrabber.repositories.responses.Location;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.User;
|
||||
import awais.instagrabber.repositories.responses.VideoVersion;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.DownloadUtils;
|
||||
import awais.instagrabber.utils.NullSafePair;
|
||||
import awais.instagrabber.utils.NumberUtils;
|
||||
@ -184,7 +184,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
// wasPaused = true;
|
||||
if (settingsHelper.getBoolean(Constants.PLAY_IN_BACKGROUND)) return;
|
||||
if (settingsHelper.getBoolean(PreferenceKeys.PLAY_IN_BACKGROUND)) return;
|
||||
final Media media = viewModel.getMedia();
|
||||
if (media == null) return;
|
||||
switch (media.getMediaType()) {
|
||||
@ -1058,7 +1058,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
||||
// gestureDetector.onTouchEvent(event);
|
||||
// return true;
|
||||
// });
|
||||
final float vol = settingsHelper.getBoolean(Constants.MUTED_VIDEOS) ? 0f : 1f;
|
||||
final float vol = settingsHelper.getBoolean(PreferenceKeys.MUTED_VIDEOS) ? 0f : 1f;
|
||||
final VideoPlayerViewHelper.VideoPlayerCallback videoPlayerCallback = new VideoPlayerCallbackAdapter() {
|
||||
@Override
|
||||
public void onThumbnailLoaded() {
|
||||
|
@ -74,6 +74,7 @@ import awais.instagrabber.asyncs.CreateThreadAction;
|
||||
import awais.instagrabber.customviews.helpers.SwipeGestureListener;
|
||||
import awais.instagrabber.databinding.FragmentStoryViewerBinding;
|
||||
import awais.instagrabber.fragments.main.ProfileFragmentDirections;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.interfaces.SwipeEvent;
|
||||
import awais.instagrabber.models.FeedStoryModel;
|
||||
import awais.instagrabber.models.HighlightModel;
|
||||
@ -109,7 +110,7 @@ import retrofit2.Response;
|
||||
|
||||
import static awais.instagrabber.customviews.helpers.SwipeGestureListener.SWIPE_THRESHOLD;
|
||||
import static awais.instagrabber.customviews.helpers.SwipeGestureListener.SWIPE_VELOCITY_THRESHOLD;
|
||||
import static awais.instagrabber.utils.Constants.MARK_AS_SEEN;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.MARK_AS_SEEN;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public class StoryViewerFragment extends Fragment {
|
||||
@ -990,7 +991,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
if (context == null) return;
|
||||
player = new SimpleExoPlayer.Builder(context).build();
|
||||
binding.playerView.setPlayer(player);
|
||||
player.setPlayWhenReady(settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS));
|
||||
player.setPlayWhenReady(settingsHelper.getBoolean(PreferenceKeys.AUTOPLAY_VIDEOS));
|
||||
|
||||
final Uri uri = Uri.parse(url);
|
||||
final MediaItem mediaItem = MediaItem.fromUri(uri);
|
||||
@ -1091,7 +1092,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
if (context == null) return;
|
||||
player = new SimpleExoPlayer.Builder(context).build();
|
||||
binding.playerView.setPlayer(player);
|
||||
player.setPlayWhenReady(settingsHelper.getBoolean(Constants.AUTOPLAY_VIDEOS));
|
||||
player.setPlayWhenReady(settingsHelper.getBoolean(PreferenceKeys.AUTOPLAY_VIDEOS));
|
||||
|
||||
final Uri uri = Uri.parse(url);
|
||||
final MediaItem mediaItem = MediaItem.fromUri(uri);
|
||||
|
@ -101,6 +101,7 @@ import awais.instagrabber.dialogs.MediaPickerBottomDialogFragment;
|
||||
import awais.instagrabber.fragments.PostViewV2Fragment;
|
||||
import awais.instagrabber.fragments.UserSearchFragment;
|
||||
import awais.instagrabber.fragments.UserSearchFragmentDirections;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.models.Resource;
|
||||
import awais.instagrabber.models.enums.DirectItemType;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
@ -114,7 +115,6 @@ import awais.instagrabber.repositories.responses.directmessages.DirectItemVisual
|
||||
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||
import awais.instagrabber.repositories.responses.directmessages.RankedRecipient;
|
||||
import awais.instagrabber.utils.AppExecutors;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.DMUtils;
|
||||
import awais.instagrabber.utils.DownloadUtils;
|
||||
import awais.instagrabber.utils.PermissionUtils;
|
||||
@ -356,7 +356,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentActivity = (MainActivity) requireActivity();
|
||||
appStateViewModel = new ViewModelProvider(fragmentActivity).get(AppStateViewModel.class);
|
||||
autoMarkAsSeen = Utils.settingsHelper.getBoolean(Constants.DM_MARK_AS_SEEN);
|
||||
autoMarkAsSeen = Utils.settingsHelper.getBoolean(PreferenceKeys.DM_MARK_AS_SEEN);
|
||||
final Bundle arguments = getArguments();
|
||||
if (arguments == null) return;
|
||||
final DirectMessageThreadFragmentArgs fragmentArgs = DirectMessageThreadFragmentArgs.fromBundle(arguments);
|
||||
|
@ -41,7 +41,7 @@ public abstract class BasePreferencesFragment extends PreferenceFragmentCompat i
|
||||
if (!shouldRecreate) return;
|
||||
final MainActivity activity = (MainActivity) getActivity();
|
||||
if (activity == null) return;
|
||||
if (key.equals(Constants.APP_LANGUAGE)) {
|
||||
if (key.equals(PreferenceKeys.APP_LANGUAGE)) {
|
||||
LocaleUtils.setLocale(activity.getBaseContext());
|
||||
}
|
||||
shouldRecreate = false;
|
||||
|
@ -20,7 +20,6 @@ import awais.instagrabber.customviews.helpers.TextWatcherAdapter;
|
||||
import awais.instagrabber.databinding.PrefAutoRefreshDmFreqBinding;
|
||||
import awais.instagrabber.services.DMSyncAlarmReceiver;
|
||||
import awais.instagrabber.services.DMSyncService;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.Debouncer;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
|
||||
@ -43,7 +42,7 @@ public class DMPreferencesFragment extends BasePreferencesFragment {
|
||||
private Preference getMarkDMSeenPreference(@NonNull final Context context) {
|
||||
return PreferenceHelper.getSwitchPreference(
|
||||
context,
|
||||
Constants.DM_MARK_AS_SEEN,
|
||||
PreferenceKeys.DM_MARK_AS_SEEN,
|
||||
R.string.dm_mark_as_seen_setting,
|
||||
R.string.dm_mark_as_seen_setting_summary,
|
||||
false,
|
||||
|
@ -14,12 +14,11 @@ import androidx.preference.SwitchPreferenceCompat;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
import awais.instagrabber.utils.DirectoryChooser;
|
||||
import awais.instagrabber.utils.TextUtils;
|
||||
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_PATH;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_SAVE_TO;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public class DownloadsPreferencesFragment extends BasePreferencesFragment {
|
||||
@ -34,7 +33,7 @@ public class DownloadsPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getDownloadUserFolderPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.DOWNLOAD_USER_FOLDER);
|
||||
preference.setKey(PreferenceKeys.DOWNLOAD_USER_FOLDER);
|
||||
preference.setTitle(R.string.download_user_folder);
|
||||
preference.setIconSpaceReserved(false);
|
||||
return preference;
|
||||
@ -52,7 +51,7 @@ public class DownloadsPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getPrependUsernameToFilenamePreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.DOWNLOAD_PREPEND_USER_NAME);
|
||||
preference.setKey(PreferenceKeys.DOWNLOAD_PREPEND_USER_NAME);
|
||||
preference.setTitle(R.string.download_prepend_username);
|
||||
preference.setIconSpaceReserved(false);
|
||||
return preference;
|
||||
@ -66,7 +65,7 @@ public class DownloadsPreferencesFragment extends BasePreferencesFragment {
|
||||
public SaveToCustomFolderPreference(final Context context, final OnSelectFolderButtonClickListener onSelectFolderButtonClickListener) {
|
||||
super(context);
|
||||
this.onSelectFolderButtonClickListener = onSelectFolderButtonClickListener;
|
||||
key = Constants.FOLDER_SAVE_TO;
|
||||
key = PreferenceKeys.FOLDER_SAVE_TO;
|
||||
setLayoutResource(R.layout.pref_custom_folder);
|
||||
setKey(key);
|
||||
setTitle(R.string.save_to_folder);
|
||||
|
@ -82,7 +82,7 @@ public class GeneralPreferencesFragment extends BasePreferencesFragment implemen
|
||||
|
||||
private Preference getUpdateCheckPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.CHECK_UPDATES);
|
||||
preference.setKey(PreferenceKeys.CHECK_UPDATES);
|
||||
preference.setTitle(R.string.update_check);
|
||||
preference.setIconSpaceReserved(false);
|
||||
return preference;
|
||||
@ -91,7 +91,7 @@ public class GeneralPreferencesFragment extends BasePreferencesFragment implemen
|
||||
private Preference getFlagSecurePreference(@NonNull final Context context) {
|
||||
return PreferenceHelper.getSwitchPreference(
|
||||
context,
|
||||
Constants.FLAG_SECURE,
|
||||
PreferenceKeys.FLAG_SECURE,
|
||||
R.string.flag_secure,
|
||||
-1,
|
||||
false,
|
||||
|
@ -36,7 +36,7 @@ public class LocalePreferencesFragment extends BasePreferencesFragment {
|
||||
for (int i = 0; i < length; i++) {
|
||||
values[i] = String.valueOf(i);
|
||||
}
|
||||
preference.setKey(Constants.APP_LANGUAGE);
|
||||
preference.setKey(PreferenceKeys.APP_LANGUAGE);
|
||||
preference.setTitle(R.string.select_language);
|
||||
preference.setDialogTitle(R.string.select_language);
|
||||
preference.setEntries(R.array.languages);
|
||||
@ -59,10 +59,10 @@ public class LocalePreferencesFragment extends BasePreferencesFragment {
|
||||
preference.setIconSpaceReserved(false);
|
||||
preference.setOnPreferenceClickListener(preference1 -> {
|
||||
new TimeSettingsDialog(
|
||||
settingsHelper.getBoolean(Constants.CUSTOM_DATE_TIME_FORMAT_ENABLED),
|
||||
settingsHelper.getString(Constants.CUSTOM_DATE_TIME_FORMAT),
|
||||
settingsHelper.getString(Constants.DATE_TIME_SELECTION),
|
||||
settingsHelper.getBoolean(Constants.SWAP_DATE_TIME_FORMAT_ENABLED),
|
||||
settingsHelper.getBoolean(PreferenceKeys.CUSTOM_DATE_TIME_FORMAT_ENABLED),
|
||||
settingsHelper.getString(PreferenceKeys.CUSTOM_DATE_TIME_FORMAT),
|
||||
settingsHelper.getString(PreferenceKeys.DATE_TIME_SELECTION),
|
||||
settingsHelper.getBoolean(PreferenceKeys.SWAP_DATE_TIME_FORMAT_ENABLED),
|
||||
(isCustomFormat,
|
||||
formatSelection,
|
||||
spTimeFormatSelectedItemPosition,
|
||||
@ -72,16 +72,16 @@ public class LocalePreferencesFragment extends BasePreferencesFragment {
|
||||
currentFormat,
|
||||
swapDateTime) -> {
|
||||
if (isCustomFormat) {
|
||||
settingsHelper.putString(Constants.CUSTOM_DATE_TIME_FORMAT, formatSelection);
|
||||
settingsHelper.putString(PreferenceKeys.CUSTOM_DATE_TIME_FORMAT, formatSelection);
|
||||
} else {
|
||||
final String formatSelectionUpdated = spTimeFormatSelectedItemPosition + ";"
|
||||
+ spSeparatorSelectedItemPosition + ';'
|
||||
+ spDateFormatSelectedItemPosition; // time;separator;date
|
||||
settingsHelper.putString(Constants.DATE_TIME_FORMAT, selectedFormat);
|
||||
settingsHelper.putString(Constants.DATE_TIME_SELECTION, formatSelectionUpdated);
|
||||
settingsHelper.putString(PreferenceKeys.DATE_TIME_FORMAT, selectedFormat);
|
||||
settingsHelper.putString(PreferenceKeys.DATE_TIME_SELECTION, formatSelectionUpdated);
|
||||
}
|
||||
settingsHelper.putBoolean(Constants.CUSTOM_DATE_TIME_FORMAT_ENABLED, isCustomFormat);
|
||||
settingsHelper.putBoolean(Constants.SWAP_DATE_TIME_FORMAT_ENABLED, swapDateTime);
|
||||
settingsHelper.putBoolean(PreferenceKeys.CUSTOM_DATE_TIME_FORMAT_ENABLED, isCustomFormat);
|
||||
settingsHelper.putBoolean(PreferenceKeys.SWAP_DATE_TIME_FORMAT_ENABLED, swapDateTime);
|
||||
Utils.datetimeParser = (SimpleDateFormat) currentFormat.clone();
|
||||
preference.setSummary(Utils.datetimeParser.format(new Date()));
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
|
||||
public class NotificationsPreferencesFragment extends BasePreferencesFragment {
|
||||
@Override
|
||||
@ -21,7 +20,7 @@ public class NotificationsPreferencesFragment extends BasePreferencesFragment {
|
||||
private Preference getActivityNotificationsPreference(@NonNull final Context context) {
|
||||
return PreferenceHelper.getSwitchPreference(
|
||||
context,
|
||||
Constants.CHECK_ACTIVITY,
|
||||
PreferenceKeys.CHECK_ACTIVITY,
|
||||
R.string.activity_setting,
|
||||
-1,
|
||||
false,
|
||||
|
@ -9,7 +9,6 @@ import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.dialogs.KeywordsFilterDialog;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
|
||||
public class PostPreferencesFragment extends BasePreferencesFragment {
|
||||
@Override
|
||||
@ -34,7 +33,7 @@ public class PostPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getBackgroundPlayPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.PLAY_IN_BACKGROUND);
|
||||
preference.setKey(PreferenceKeys.PLAY_IN_BACKGROUND);
|
||||
preference.setTitle(R.string.post_viewer_background_play);
|
||||
preference.setSummary(R.string.post_viewer_background_play_summary);
|
||||
preference.setIconSpaceReserved(false);
|
||||
@ -43,7 +42,7 @@ public class PostPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getAlwaysMuteVideosPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.MUTED_VIDEOS);
|
||||
preference.setKey(PreferenceKeys.MUTED_VIDEOS);
|
||||
preference.setTitle(R.string.post_viewer_muted_autoplay);
|
||||
preference.setIconSpaceReserved(false);
|
||||
return preference;
|
||||
@ -51,7 +50,7 @@ public class PostPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getShowCaptionPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.SHOW_CAPTIONS);
|
||||
preference.setKey(PreferenceKeys.SHOW_CAPTIONS);
|
||||
preference.setDefaultValue(true);
|
||||
preference.setTitle(R.string.post_viewer_show_captions);
|
||||
preference.setIconSpaceReserved(false);
|
||||
@ -60,7 +59,7 @@ public class PostPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getToggleKeywordFilterPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.TOGGLE_KEYWORD_FILTER);
|
||||
preference.setKey(PreferenceKeys.TOGGLE_KEYWORD_FILTER);
|
||||
preference.setDefaultValue(false);
|
||||
preference.setTitle(R.string.toggle_keyword_filter);
|
||||
preference.setIconSpaceReserved(false);
|
||||
|
@ -8,4 +8,36 @@ public final class PreferenceKeys {
|
||||
public static final String PREF_ENABLE_SENTRY = "enable_sentry";
|
||||
public static final String PREF_TAB_ORDER = "tab_order";
|
||||
public static final String PREF_SHOWN_COUNT_TOOLTIP = "shown_count_tooltip";
|
||||
// string prefs
|
||||
public static final String FOLDER_PATH = "custom_path";
|
||||
public static final String DATE_TIME_FORMAT = "date_time_format";
|
||||
public static final String DATE_TIME_SELECTION = "date_time_selection";
|
||||
public static final String CUSTOM_DATE_TIME_FORMAT = "date_time_custom_format";
|
||||
public static final String APP_THEME = "app_theme_v19";
|
||||
public static final String APP_LANGUAGE = "app_language_v19";
|
||||
public static final String STORY_SORT = "story_sort";
|
||||
// set string prefs
|
||||
public static final String KEYWORD_FILTERS = "keyword_filters";
|
||||
// boolean prefs
|
||||
public static final String DOWNLOAD_USER_FOLDER = "download_user_folder";
|
||||
public static final String TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter";
|
||||
public static final String DOWNLOAD_PREPEND_USER_NAME = "download_user_name";
|
||||
public static final String PLAY_IN_BACKGROUND = "play_in_background";
|
||||
// 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";
|
||||
public static final String SHOW_CAPTIONS = "show_captions";
|
||||
public static final String CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled";
|
||||
public static final String SWAP_DATE_TIME_FORMAT_ENABLED = "swap_date_time_enabled";
|
||||
public static final String MARK_AS_SEEN = "mark_as_seen";
|
||||
public static final String HIDE_MUTED_REELS = "hide_muted_reels";
|
||||
public static final String DM_MARK_AS_SEEN = "dm_mark_as_seen";
|
||||
// deprecated: public static final String INSTADP = "instadp";
|
||||
// deprecated: public static final String STORIESIG = "storiesig";
|
||||
// deprecated: public static final String STORY_VIEWER = "story_viewer";
|
||||
// deprecated: public static final String AMOLED_THEME = "amoled_theme";
|
||||
public static final String CHECK_ACTIVITY = "check_activity";
|
||||
public static final String CHECK_UPDATES = "check_updates";
|
||||
public static final String FLAG_SECURE = "flag_secure";
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreferenceCompat;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
|
||||
public class StoriesPreferencesFragment extends BasePreferencesFragment {
|
||||
@Override
|
||||
@ -29,7 +28,7 @@ public class StoriesPreferencesFragment extends BasePreferencesFragment {
|
||||
for (int i = 0; i < length; i++) {
|
||||
values[i] = String.valueOf(i);
|
||||
}
|
||||
preference.setKey(Constants.STORY_SORT);
|
||||
preference.setKey(PreferenceKeys.STORY_SORT);
|
||||
preference.setTitle(R.string.story_sort_setting);
|
||||
preference.setDialogTitle(R.string.story_sort_setting);
|
||||
preference.setEntries(R.array.story_sorts);
|
||||
@ -40,7 +39,7 @@ public class StoriesPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getHideMutedReelsPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.HIDE_MUTED_REELS);
|
||||
preference.setKey(PreferenceKeys.HIDE_MUTED_REELS);
|
||||
preference.setTitle(R.string.hide_muted_reels_setting);
|
||||
preference.setIconSpaceReserved(false);
|
||||
return preference;
|
||||
@ -48,7 +47,7 @@ public class StoriesPreferencesFragment extends BasePreferencesFragment {
|
||||
|
||||
private Preference getMarkStoriesSeenPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(Constants.MARK_AS_SEEN);
|
||||
preference.setKey(PreferenceKeys.MARK_AS_SEEN);
|
||||
preference.setTitle(R.string.mark_as_seen_setting);
|
||||
preference.setSummary(R.string.mark_as_seen_setting_summary);
|
||||
preference.setIconSpaceReserved(false);
|
||||
|
@ -29,7 +29,7 @@ public class ThemePreferencesFragment extends BasePreferencesFragment {
|
||||
for (int i = 0; i < length; i++) {
|
||||
values[i] = String.valueOf(i);
|
||||
}
|
||||
preference.setKey(Constants.APP_THEME);
|
||||
preference.setKey(PreferenceKeys.APP_THEME);
|
||||
preference.setTitle(R.string.theme_settings);
|
||||
preference.setDialogTitle(R.string.theme_settings);
|
||||
preference.setEntries(R.array.theme_presets);
|
||||
|
@ -3,42 +3,10 @@ package awais.instagrabber.utils;
|
||||
public final class Constants {
|
||||
public static final String CRASH_REPORT_EMAIL = "barinsta@austinhuang.me";
|
||||
|
||||
// string prefs
|
||||
public static final String FOLDER_PATH = "custom_path";
|
||||
public static final String DATE_TIME_FORMAT = "date_time_format";
|
||||
public static final String DATE_TIME_SELECTION = "date_time_selection";
|
||||
public static final String CUSTOM_DATE_TIME_FORMAT = "date_time_custom_format";
|
||||
public static final String APP_THEME = "app_theme_v19";
|
||||
public static final String APP_LANGUAGE = "app_language_v19";
|
||||
public static final String STORY_SORT = "story_sort";
|
||||
// set string prefs
|
||||
public static final String KEYWORD_FILTERS = "keyword_filters";
|
||||
// int prefs, do not export
|
||||
public static final String PREV_INSTALL_VERSION = "prevVersion";
|
||||
public static final String BROWSER_UA_CODE = "browser_ua_code";
|
||||
public static final String APP_UA_CODE = "app_ua_code";
|
||||
// boolean prefs
|
||||
public static final String DOWNLOAD_USER_FOLDER = "download_user_folder";
|
||||
public static final String TOGGLE_KEYWORD_FILTER = "toggle_keyword_filter";
|
||||
public static final String DOWNLOAD_PREPEND_USER_NAME = "download_user_name";
|
||||
public static final String PLAY_IN_BACKGROUND = "play_in_background";
|
||||
// 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";
|
||||
public static final String SHOW_CAPTIONS = "show_captions";
|
||||
public static final String CUSTOM_DATE_TIME_FORMAT_ENABLED = "data_time_custom_enabled";
|
||||
public static final String SWAP_DATE_TIME_FORMAT_ENABLED = "swap_date_time_enabled";
|
||||
public static final String MARK_AS_SEEN = "mark_as_seen";
|
||||
public static final String HIDE_MUTED_REELS = "hide_muted_reels";
|
||||
public static final String DM_MARK_AS_SEEN = "dm_mark_as_seen";
|
||||
// deprecated: public static final String INSTADP = "instadp";
|
||||
// deprecated: public static final String STORIESIG = "storiesig";
|
||||
// deprecated: public static final String STORY_VIEWER = "story_viewer";
|
||||
// deprecated: public static final String AMOLED_THEME = "amoled_theme";
|
||||
public static final String CHECK_ACTIVITY = "check_activity";
|
||||
public static final String CHECK_UPDATES = "check_updates";
|
||||
public static final String FLAG_SECURE = "flag_secure";
|
||||
// never Export
|
||||
public static final String COOKIE = "cookie";
|
||||
public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg";
|
||||
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
import awais.instagrabber.repositories.responses.Audio;
|
||||
@ -41,8 +42,8 @@ import awais.instagrabber.repositories.responses.User;
|
||||
import awais.instagrabber.repositories.responses.VideoVersion;
|
||||
import awais.instagrabber.workers.DownloadWorker;
|
||||
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_PATH;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_SAVE_TO;
|
||||
|
||||
public final class DownloadUtils {
|
||||
private static final String TAG = "DownloadUtils";
|
||||
@ -74,7 +75,7 @@ public final class DownloadUtils {
|
||||
final boolean skipCreateDir) {
|
||||
File dir = getDownloadDir();
|
||||
|
||||
if (Utils.settingsHelper.getBoolean(Constants.DOWNLOAD_USER_FOLDER) && !TextUtils.isEmpty(username)) {
|
||||
if (Utils.settingsHelper.getBoolean(PreferenceKeys.DOWNLOAD_USER_FOLDER) && !TextUtils.isEmpty(username)) {
|
||||
final String finaleUsername = username.startsWith("@") ? username.substring(1) : username;
|
||||
dir = new File(dir, finaleUsername);
|
||||
}
|
||||
@ -277,7 +278,7 @@ public final class DownloadUtils {
|
||||
: storyModel.getStoryUrl();
|
||||
final String baseFileName = storyModel.getStoryMediaId() + "_"
|
||||
+ storyModel.getTimestamp() + DownloadUtils.getFileExtensionFromUrl(url);
|
||||
final String usernamePrepend = Utils.settingsHelper.getBoolean(Constants.DOWNLOAD_PREPEND_USER_NAME)
|
||||
final String usernamePrepend = Utils.settingsHelper.getBoolean(PreferenceKeys.DOWNLOAD_PREPEND_USER_NAME)
|
||||
&& storyModel.getUsername() != null ? storyModel.getUsername() + "_" : "";
|
||||
final File saveFile = new File(downloadDir,
|
||||
usernamePrepend + baseFileName);
|
||||
@ -318,7 +319,7 @@ public final class DownloadUtils {
|
||||
}
|
||||
if (!TextUtils.isEmpty(media.getCode())) {
|
||||
fileName = media.getCode();
|
||||
if (Utils.settingsHelper.getBoolean(Constants.DOWNLOAD_PREPEND_USER_NAME) && mediaUser != null) {
|
||||
if (Utils.settingsHelper.getBoolean(PreferenceKeys.DOWNLOAD_PREPEND_USER_NAME) && mediaUser != null) {
|
||||
fileName = mediaUser.getUsername() + "_" + fileName;
|
||||
}
|
||||
}
|
||||
@ -344,7 +345,7 @@ public final class DownloadUtils {
|
||||
}
|
||||
final Media child = sliderItems.get(i);
|
||||
final String url = getUrlOfType(child);
|
||||
final String usernamePrepend = Utils.settingsHelper.getBoolean(Constants.DOWNLOAD_PREPEND_USER_NAME) && mediaUser != null ? mediaUser.getUsername() : "";
|
||||
final String usernamePrepend = Utils.settingsHelper.getBoolean(PreferenceKeys.DOWNLOAD_PREPEND_USER_NAME) && mediaUser != null ? mediaUser.getUsername() : "";
|
||||
final File file = getDownloadChildSaveFile(downloadDir, media.getCode(), i + 1, url, usernamePrepend);
|
||||
map.put(url, file.getAbsolutePath());
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
|
||||
// taken from my app TESV Console Codes
|
||||
public final class LocaleUtils {
|
||||
private static Locale defaultLocale, currentLocale;
|
||||
@ -22,7 +24,7 @@ public final class LocaleUtils {
|
||||
if (Utils.settingsHelper == null)
|
||||
Utils.settingsHelper = new SettingsHelper(baseContext);
|
||||
|
||||
final String appLanguageSettings = Utils.settingsHelper.getString(Constants.APP_LANGUAGE);
|
||||
final String appLanguageSettings = Utils.settingsHelper.getString(PreferenceKeys.APP_LANGUAGE);
|
||||
final String lang = LocaleUtils.getCorrespondingLanguageCode(appLanguageSettings);
|
||||
|
||||
currentLocale = TextUtils.isEmpty(lang) ? defaultLocale :
|
||||
|
@ -18,33 +18,33 @@ import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_ENABLE_D
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_ENABLE_SENTRY;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_SHOWN_COUNT_TOOLTIP;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_TAB_ORDER;
|
||||
import static awais.instagrabber.utils.Constants.APP_LANGUAGE;
|
||||
import static awais.instagrabber.utils.Constants.APP_THEME;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.APP_LANGUAGE;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.APP_THEME;
|
||||
import static awais.instagrabber.utils.Constants.APP_UA;
|
||||
import static awais.instagrabber.utils.Constants.APP_UA_CODE;
|
||||
import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.AUTOPLAY_VIDEOS;
|
||||
import static awais.instagrabber.utils.Constants.BROWSER_UA;
|
||||
import static awais.instagrabber.utils.Constants.BROWSER_UA_CODE;
|
||||
import static awais.instagrabber.utils.Constants.CHECK_ACTIVITY;
|
||||
import static awais.instagrabber.utils.Constants.CHECK_UPDATES;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.CHECK_ACTIVITY;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.CHECK_UPDATES;
|
||||
import static awais.instagrabber.utils.Constants.COOKIE;
|
||||
import static awais.instagrabber.utils.Constants.CUSTOM_DATE_TIME_FORMAT;
|
||||
import static awais.instagrabber.utils.Constants.CUSTOM_DATE_TIME_FORMAT_ENABLED;
|
||||
import static awais.instagrabber.utils.Constants.DATE_TIME_FORMAT;
|
||||
import static awais.instagrabber.utils.Constants.DATE_TIME_SELECTION;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.CUSTOM_DATE_TIME_FORMAT;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.CUSTOM_DATE_TIME_FORMAT_ENABLED;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.DATE_TIME_FORMAT;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.DATE_TIME_SELECTION;
|
||||
import static awais.instagrabber.utils.Constants.DEFAULT_TAB;
|
||||
import static awais.instagrabber.utils.Constants.DEVICE_UUID;
|
||||
import static awais.instagrabber.utils.Constants.DM_MARK_AS_SEEN;
|
||||
import static awais.instagrabber.utils.Constants.DOWNLOAD_PREPEND_USER_NAME;
|
||||
import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER;
|
||||
import static awais.instagrabber.utils.Constants.FLAG_SECURE;
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_PATH;
|
||||
import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO;
|
||||
import static awais.instagrabber.utils.Constants.HIDE_MUTED_REELS;
|
||||
import static awais.instagrabber.utils.Constants.KEYWORD_FILTERS;
|
||||
import static awais.instagrabber.utils.Constants.MARK_AS_SEEN;
|
||||
import static awais.instagrabber.utils.Constants.MUTED_VIDEOS;
|
||||
import static awais.instagrabber.utils.Constants.PLAY_IN_BACKGROUND;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.DM_MARK_AS_SEEN;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.DOWNLOAD_PREPEND_USER_NAME;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.DOWNLOAD_USER_FOLDER;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FLAG_SECURE;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_PATH;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.FOLDER_SAVE_TO;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.HIDE_MUTED_REELS;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.KEYWORD_FILTERS;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.MARK_AS_SEEN;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.MUTED_VIDEOS;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PLAY_IN_BACKGROUND;
|
||||
import static awais.instagrabber.utils.Constants.PREF_DARK_THEME;
|
||||
import static awais.instagrabber.utils.Constants.PREF_EMOJI_VARIANTS;
|
||||
import static awais.instagrabber.utils.Constants.PREF_HASHTAG_POSTS_LAYOUT;
|
||||
@ -58,12 +58,12 @@ import static awais.instagrabber.utils.Constants.PREF_SAVED_POSTS_LAYOUT;
|
||||
import static awais.instagrabber.utils.Constants.PREF_TAGGED_POSTS_LAYOUT;
|
||||
import static awais.instagrabber.utils.Constants.PREF_TOPIC_POSTS_LAYOUT;
|
||||
import static awais.instagrabber.utils.Constants.PREV_INSTALL_VERSION;
|
||||
import static awais.instagrabber.utils.Constants.SHOW_CAPTIONS;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.SHOW_CAPTIONS;
|
||||
import static awais.instagrabber.utils.Constants.SHOW_QUICK_ACCESS_DIALOG;
|
||||
import static awais.instagrabber.utils.Constants.SKIPPED_VERSION;
|
||||
import static awais.instagrabber.utils.Constants.STORY_SORT;
|
||||
import static awais.instagrabber.utils.Constants.SWAP_DATE_TIME_FORMAT_ENABLED;
|
||||
import static awais.instagrabber.utils.Constants.TOGGLE_KEYWORD_FILTER;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.STORY_SORT;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.SWAP_DATE_TIME_FORMAT_ENABLED;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.TOGGLE_KEYWORD_FILTER;
|
||||
|
||||
public final class SettingsHelper {
|
||||
private final SharedPreferences sharedPreferences;
|
||||
|
@ -17,12 +17,12 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import awais.instagrabber.fragments.settings.PreferenceKeys;
|
||||
import awais.instagrabber.models.FeedStoryModel;
|
||||
import awais.instagrabber.models.HighlightModel;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
import awais.instagrabber.repositories.StoriesRepository;
|
||||
import awais.instagrabber.repositories.requests.StoryViewerOptions;
|
||||
import awais.instagrabber.repositories.responses.FriendshipStatus;
|
||||
import awais.instagrabber.repositories.responses.StoryStickerResponse;
|
||||
import awais.instagrabber.repositories.responses.User;
|
||||
import awais.instagrabber.utils.Constants;
|
||||
@ -135,7 +135,7 @@ public class StoriesService extends BaseService {
|
||||
final JSONArray feedStoriesReel = new JSONObject(body).getJSONArray("tray");
|
||||
for (int i = 0; i < feedStoriesReel.length(); ++i) {
|
||||
final JSONObject node = feedStoriesReel.getJSONObject(i);
|
||||
if (node.optBoolean("hide_from_feed_unit") && Utils.settingsHelper.getBoolean(Constants.HIDE_MUTED_REELS)) continue;
|
||||
if (node.optBoolean("hide_from_feed_unit") && Utils.settingsHelper.getBoolean(PreferenceKeys.HIDE_MUTED_REELS)) continue;
|
||||
final JSONObject userJson = node.getJSONObject(node.has("user") ? "user" : "owner");
|
||||
try {
|
||||
final User user = new User(userJson.getLong("pk"),
|
||||
@ -505,7 +505,7 @@ public class StoriesService extends BaseService {
|
||||
final List<FeedStoryModel> listCopy = new ArrayList<>(list);
|
||||
Collections.sort(listCopy, (o1, o2) -> {
|
||||
int result;
|
||||
switch (Utils.settingsHelper.getString(Constants.STORY_SORT)) {
|
||||
switch (Utils.settingsHelper.getString(PreferenceKeys.STORY_SORT)) {
|
||||
case "1":
|
||||
result = Long.compare(o2.getTimestamp(), o1.getTimestamp());
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user