mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
Merge branch 'master' into raniapl/development
This commit is contained in:
commit
f501f68f98
@ -51,8 +51,6 @@
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="ig.me" />
|
||||
<data android:host="www.ig.me" />
|
||||
<data android:host="instagr.am" />
|
||||
<data android:host="www.instagr.am" />
|
||||
<data android:host="instagram.com" />
|
||||
@ -60,6 +58,7 @@
|
||||
<data android:pathPrefix="/" />
|
||||
<data android:pathPrefix="/p" />
|
||||
<data android:pathPrefix="/explore/tags" />
|
||||
<data android:pathPrefix="/explore/locations" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
@ -104,14 +103,6 @@
|
||||
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:host="ig.me" />
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activities.Login"
|
||||
|
@ -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);
|
||||
|
@ -11,6 +11,7 @@ import androidx.recyclerview.widget.ListAdapter;
|
||||
import awais.instagrabber.adapters.viewholder.TopicClusterViewHolder;
|
||||
import awais.instagrabber.databinding.ItemDiscoverTopicBinding;
|
||||
import awais.instagrabber.repositories.responses.discover.TopicCluster;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.utils.ResponseBodyUtils;
|
||||
|
||||
public class DiscoverTopicsAdapter extends ListAdapter<TopicCluster, TopicClusterViewHolder> {
|
||||
@ -50,6 +51,8 @@ public class DiscoverTopicsAdapter extends ListAdapter<TopicCluster, TopicCluste
|
||||
}
|
||||
|
||||
public interface OnTopicClickListener {
|
||||
void onTopicClick(TopicCluster topicCluster, View root, View cover, View title, int titleColor, int backgroundColor);
|
||||
void onTopicClick(TopicCluster topicCluster, View cover, int titleColor, int backgroundColor);
|
||||
|
||||
void onTopicLongClick(Media coverMedia);
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
package awais.instagrabber.adapters.viewholder;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
|
||||
public final class DiscoverViewHolder extends RecyclerView.ViewHolder {
|
||||
public final SimpleDraweeView postImage;
|
||||
public final ImageView typeIcon;
|
||||
public final View selectedView;
|
||||
// public final View progressView;
|
||||
|
||||
public DiscoverViewHolder(@NonNull final View itemView) {
|
||||
super(itemView);
|
||||
typeIcon = itemView.findViewById(R.id.typeIcon);
|
||||
postImage = itemView.findViewById(R.id.postImage);
|
||||
selectedView = itemView.findViewById(R.id.selectedView);
|
||||
// progressView = itemView.findViewById(R.id.progressView);
|
||||
}
|
||||
}
|
||||
//package awais.instagrabber.adapters.viewholder;
|
||||
//
|
||||
//import android.view.View;
|
||||
//import android.widget.ImageView;
|
||||
//
|
||||
//import androidx.annotation.NonNull;
|
||||
//import androidx.recyclerview.widget.RecyclerView;
|
||||
//
|
||||
//import com.facebook.drawee.view.SimpleDraweeView;
|
||||
//
|
||||
//import awais.instagrabber.R;
|
||||
//
|
||||
//public final class DiscoverViewHolder extends RecyclerView.ViewHolder {
|
||||
// public final SimpleDraweeView postImage;
|
||||
// public final ImageView typeIcon;
|
||||
// public final View selectedView;
|
||||
// // public final View progressView;
|
||||
//
|
||||
// public DiscoverViewHolder(@NonNull final View itemView) {
|
||||
// super(itemView);
|
||||
// typeIcon = itemView.findViewById(R.id.typeIcon);
|
||||
// postImage = itemView.findViewById(R.id.postImage);
|
||||
// selectedView = itemView.findViewById(R.id.selectedView);
|
||||
// // progressView = itemView.findViewById(R.id.progressView);
|
||||
// }
|
||||
//}
|
@ -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
|
||||
|
@ -54,12 +54,14 @@ public class TopicClusterViewHolder extends RecyclerView.ViewHolder {
|
||||
if (onTopicClickListener != null) {
|
||||
itemView.setOnClickListener(v -> onTopicClickListener.onTopicClick(
|
||||
topicCluster,
|
||||
binding.getRoot(),
|
||||
binding.cover,
|
||||
binding.title,
|
||||
titleColor.get(),
|
||||
backgroundColor.get()
|
||||
));
|
||||
itemView.setOnLongClickListener(v -> {
|
||||
onTopicClickListener.onTopicLongClick(topicCluster.getCoverMedia());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
// binding.title.setTransitionName("title-" + topicCluster.getId());
|
||||
binding.cover.setTransitionName("cover-" + topicCluster.getId());
|
||||
|
@ -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 {
|
||||
|
@ -114,6 +114,7 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe
|
||||
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);
|
||||
try {
|
||||
navController.navigate(R.id.action_global_post_view, bundle);
|
||||
alertDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onSuccess: ", e);
|
||||
}
|
||||
|
@ -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 {
|
||||
@ -448,7 +449,10 @@ public class StoryViewerFragment extends Fragment {
|
||||
binding.swipeUp.setOnClickListener(v -> {
|
||||
final Object tag = v.getTag();
|
||||
if (tag instanceof CharSequence) {
|
||||
Utils.openURL(context, tag.toString());
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.swipe_up_confirmation)
|
||||
.setMessage(tag.toString()).setPositiveButton(R.string.yes, (d, w) -> Utils.openURL(context, tag.toString()))
|
||||
.setNegativeButton(R.string.no, (d, w) -> d.dismiss()).show();
|
||||
}
|
||||
});
|
||||
binding.viewStoryPost.setOnClickListener(v -> {
|
||||
@ -468,6 +472,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);
|
||||
try {
|
||||
navController.navigate(R.id.action_global_post_view, bundle);
|
||||
alertDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openPostDialog: ", e);
|
||||
}
|
||||
@ -990,7 +995,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 +1096,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);
|
||||
|
@ -5,24 +5,35 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.fragment.FragmentNavigator;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.MainActivity;
|
||||
import awais.instagrabber.adapters.DiscoverTopicsAdapter;
|
||||
import awais.instagrabber.customviews.helpers.GridSpacingItemDecoration;
|
||||
import awais.instagrabber.databinding.FragmentDiscoverBinding;
|
||||
import awais.instagrabber.fragments.PostViewV2Fragment;
|
||||
import awais.instagrabber.repositories.responses.Media;
|
||||
import awais.instagrabber.repositories.responses.discover.TopicCluster;
|
||||
import awais.instagrabber.repositories.responses.discover.TopicalExploreFeedResponse;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.viewmodels.TopicClusterViewModel;
|
||||
import awais.instagrabber.webservices.DiscoverService;
|
||||
import awais.instagrabber.webservices.MediaService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
|
||||
public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
@ -34,12 +45,14 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
private TopicClusterViewModel topicClusterViewModel;
|
||||
private boolean shouldRefresh = true;
|
||||
private DiscoverService discoverService;
|
||||
private MediaService mediaService;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentActivity = (MainActivity) requireActivity();
|
||||
discoverService = DiscoverService.getInstance();
|
||||
mediaService = MediaService.getInstance(null, null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,13 +89,47 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
public void setupTopics() {
|
||||
topicClusterViewModel = new ViewModelProvider(fragmentActivity).get(TopicClusterViewModel.class);
|
||||
binding.topicsRecyclerView.addItemDecoration(new GridSpacingItemDecoration(Utils.convertDpToPx(2)));
|
||||
final DiscoverTopicsAdapter adapter = new DiscoverTopicsAdapter((topicCluster, root, cover, title, titleColor, backgroundColor) -> {
|
||||
final FragmentNavigator.Extras.Builder builder = new FragmentNavigator.Extras.Builder()
|
||||
.addSharedElement(cover, "cover-" + topicCluster.getId());
|
||||
final DiscoverFragmentDirections.ActionDiscoverFragmentToTopicPostsFragment action = DiscoverFragmentDirections
|
||||
.actionDiscoverFragmentToTopicPostsFragment(topicCluster, titleColor, backgroundColor);
|
||||
NavHostFragment.findNavController(this).navigate(action, builder.build());
|
||||
});
|
||||
final DiscoverTopicsAdapter.OnTopicClickListener otcl = new DiscoverTopicsAdapter.OnTopicClickListener() {
|
||||
public void onTopicClick(final TopicCluster topicCluster, final View cover, final int titleColor, final int backgroundColor) {
|
||||
final FragmentNavigator.Extras.Builder builder = new FragmentNavigator.Extras.Builder()
|
||||
.addSharedElement(cover, "cover-" + topicCluster.getId());
|
||||
final DiscoverFragmentDirections.ActionDiscoverFragmentToTopicPostsFragment action = DiscoverFragmentDirections
|
||||
.actionDiscoverFragmentToTopicPostsFragment(topicCluster, titleColor, backgroundColor);
|
||||
NavHostFragment.findNavController(DiscoverFragment.this).navigate(action, builder.build());
|
||||
}
|
||||
|
||||
public void onTopicLongClick(final Media coverMedia) {
|
||||
final AlertDialog alertDialog = new AlertDialog.Builder(requireContext())
|
||||
.setCancelable(false)
|
||||
.setView(R.layout.dialog_opening_post)
|
||||
.create();
|
||||
alertDialog.show();
|
||||
mediaService.fetch(Long.valueOf(coverMedia.getPk()), new ServiceCallback<Media>() {
|
||||
@Override
|
||||
public void onSuccess(final Media feedModel) {
|
||||
final NavController navController = NavHostFragment.findNavController(DiscoverFragment.this);
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(PostViewV2Fragment.ARG_MEDIA, feedModel);
|
||||
try {
|
||||
navController.navigate(R.id.action_global_post_view, bundle);
|
||||
alertDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onSuccess: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable t) {
|
||||
alertDialog.dismiss();
|
||||
try {
|
||||
Toast.makeText(requireContext(), R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
catch (Throwable e) {}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
final DiscoverTopicsAdapter adapter = new DiscoverTopicsAdapter(otcl);
|
||||
binding.topicsRecyclerView.setAdapter(adapter);
|
||||
topicClusterViewModel.getList().observe(getViewLifecycleOwner(), adapter::submitList);
|
||||
}
|
||||
@ -93,8 +140,18 @@ public class DiscoverFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
@Override
|
||||
public void onSuccess(final TopicalExploreFeedResponse result) {
|
||||
if (result == null) return;
|
||||
topicClusterViewModel.getList().postValue(result.getClusters());
|
||||
final List<TopicCluster> clusters = result.getClusters();
|
||||
binding.swipeRefreshLayout.setRefreshing(false);
|
||||
if (clusters.size() == 1 && result.getItems().size() > 0) {
|
||||
final TopicCluster cluster = clusters.get(0);
|
||||
if (cluster.getCoverMedia() == null)
|
||||
cluster.setCoverMedia(result.getItems().get(0).getMedia());
|
||||
topicClusterViewModel.getList().postValue(Collections.singletonList(cluster));
|
||||
return;
|
||||
}
|
||||
if (clusters.size() > 1 || result.getItems().size() == 0) {
|
||||
topicClusterViewModel.getList().postValue(clusters);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package awais.instagrabber.fragments.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
@ -7,6 +8,7 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@ -36,6 +38,9 @@ import awais.instagrabber.models.enums.FavoriteType;
|
||||
import awais.instagrabber.repositories.responses.search.SearchItem;
|
||||
import awais.instagrabber.viewmodels.SearchFragmentViewModel;
|
||||
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_SEARCH_FOCUS_KEYBOARD;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public class SearchFragment extends Fragment implements SearchCategoryFragment.OnSearchItemClickListener {
|
||||
private static final String TAG = SearchFragment.class.getSimpleName();
|
||||
private static final String QUERY = "query";
|
||||
@ -119,9 +124,11 @@ public class SearchFragment extends Fragment implements SearchCategoryFragment.O
|
||||
if (mainActivity != null) {
|
||||
mainActivity.showSearchView();
|
||||
}
|
||||
// if (searchInputLayout != null) {
|
||||
// searchInputLayout.requestFocus();
|
||||
// }
|
||||
if (settingsHelper.getBoolean(PREF_SEARCH_FOCUS_KEYBOARD)) {
|
||||
searchInput.requestFocus();
|
||||
final InputMethodManager imm = (InputMethodManager) requireContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) imm.showSoftInput(searchInput, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}
|
||||
|
||||
private void init(@Nullable final Bundle savedInstanceState) {
|
||||
@ -147,7 +154,11 @@ public class SearchFragment extends Fragment implements SearchCategoryFragment.O
|
||||
searchInput.setText(savedQuery);
|
||||
triggerEmptyQuery = false;
|
||||
}
|
||||
// searchInput.requestFocus();
|
||||
if (settingsHelper.getBoolean(PREF_SEARCH_FOCUS_KEYBOARD)) {
|
||||
searchInput.requestFocus();
|
||||
final InputMethodManager imm = (InputMethodManager) requireContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) imm.showSoftInput(searchInput, InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
if (triggerEmptyQuery) {
|
||||
viewModel.submitQuery("");
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -36,6 +36,7 @@ public class GeneralPreferencesFragment extends BasePreferencesFragment implemen
|
||||
}
|
||||
screen.addPreference(getUpdateCheckPreference(context));
|
||||
screen.addPreference(getFlagSecurePreference(context));
|
||||
screen.addPreference(getSearchFocusPreference(context));
|
||||
final List<Preference> preferences = FlavorSettings.getInstance()
|
||||
.getPreferences(context,
|
||||
getChildFragmentManager(),
|
||||
@ -82,7 +83,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 +92,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,
|
||||
@ -101,6 +102,14 @@ public class GeneralPreferencesFragment extends BasePreferencesFragment implemen
|
||||
});
|
||||
}
|
||||
|
||||
private Preference getSearchFocusPreference(@NonNull final Context context) {
|
||||
final SwitchPreferenceCompat preference = new SwitchPreferenceCompat(context);
|
||||
preference.setKey(PreferenceKeys.PREF_SEARCH_FOCUS_KEYBOARD);
|
||||
preference.setTitle(R.string.pref_search_focus_keyboard);
|
||||
preference.setIconSpaceReserved(false);
|
||||
return preference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSave(final boolean orderHasChanged) {
|
||||
if (!orderHasChanged) return;
|
||||
|
@ -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);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package awais.instagrabber.fragments.settings;
|
||||
|
||||
public final class PreferenceKeys {
|
||||
// new boolean prefs
|
||||
public static final String PREF_ENABLE_DM_NOTIFICATIONS = "enable_dm_notifications";
|
||||
public static final String PREF_ENABLE_DM_AUTO_REFRESH = "enable_dm_auto_refresh";
|
||||
public static final String PREF_ENABLE_DM_AUTO_REFRESH_FREQ_UNIT = "enable_dm_auto_refresh_freq_unit";
|
||||
@ -8,4 +9,32 @@ 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";
|
||||
public static final String PREF_SEARCH_FOCUS_KEYBOARD = "search_focus_keyboard";
|
||||
// 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";
|
||||
// old 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";
|
||||
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";
|
||||
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);
|
||||
|
@ -11,7 +11,7 @@ public class TopicCluster implements Serializable {
|
||||
private final boolean canMute;
|
||||
private final boolean isMuted;
|
||||
private final int rankedPosition;
|
||||
private final Media coverMedia;
|
||||
private Media coverMedia;
|
||||
|
||||
public TopicCluster(final String id,
|
||||
final String title,
|
||||
@ -56,4 +56,8 @@ public class TopicCluster implements Serializable {
|
||||
public Media getCoverMedia() {
|
||||
return coverMedia;
|
||||
}
|
||||
|
||||
public void setCoverMedia(final Media coverMedia) {
|
||||
this.coverMedia = coverMedia;
|
||||
}
|
||||
}
|
||||
|
@ -3,45 +3,13 @@ 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";
|
||||
// deprecated: public static final String SHOW_QUICK_ACCESS_DIALOG = "show_quick_dlg";
|
||||
public static final String DEVICE_UUID = "device_uuid";
|
||||
public static final String BROWSER_UA = "browser_ua";
|
||||
public static final String APP_UA = "app_ua";
|
||||
|
@ -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.utils.Constants.SHOW_QUICK_ACCESS_DIALOG;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_SEARCH_FOCUS_KEYBOARD;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.SHOW_CAPTIONS;
|
||||
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;
|
||||
@ -155,18 +155,18 @@ public final class SettingsHelper {
|
||||
return sharedPreferences != null && sharedPreferences.contains(key);
|
||||
}
|
||||
|
||||
@StringDef(
|
||||
{APP_LANGUAGE, APP_THEME, APP_UA, BROWSER_UA, COOKIE, FOLDER_PATH, DATE_TIME_FORMAT, DATE_TIME_SELECTION,
|
||||
@StringDef({APP_LANGUAGE, APP_THEME, APP_UA, BROWSER_UA, COOKIE, FOLDER_PATH, DATE_TIME_FORMAT, DATE_TIME_SELECTION,
|
||||
CUSTOM_DATE_TIME_FORMAT, DEVICE_UUID, SKIPPED_VERSION, DEFAULT_TAB, PREF_DARK_THEME, PREF_LIGHT_THEME,
|
||||
PREF_POSTS_LAYOUT, PREF_PROFILE_POSTS_LAYOUT, PREF_TOPIC_POSTS_LAYOUT, PREF_HASHTAG_POSTS_LAYOUT,
|
||||
PREF_LOCATION_POSTS_LAYOUT, PREF_LIKED_POSTS_LAYOUT, PREF_TAGGED_POSTS_LAYOUT, PREF_SAVED_POSTS_LAYOUT,
|
||||
STORY_SORT, PREF_EMOJI_VARIANTS, PREF_REACTIONS, PREF_ENABLE_DM_AUTO_REFRESH_FREQ_UNIT, PREF_TAB_ORDER})
|
||||
public @interface StringSettings {}
|
||||
|
||||
@StringDef({DOWNLOAD_USER_FOLDER, DOWNLOAD_PREPEND_USER_NAME, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, SHOW_QUICK_ACCESS_DIALOG, MUTED_VIDEOS,
|
||||
@StringDef({DOWNLOAD_USER_FOLDER, DOWNLOAD_PREPEND_USER_NAME, FOLDER_SAVE_TO, AUTOPLAY_VIDEOS, MUTED_VIDEOS,
|
||||
SHOW_CAPTIONS, CUSTOM_DATE_TIME_FORMAT_ENABLED, MARK_AS_SEEN, DM_MARK_AS_SEEN, CHECK_ACTIVITY,
|
||||
CHECK_UPDATES, SWAP_DATE_TIME_FORMAT_ENABLED, PREF_ENABLE_DM_NOTIFICATIONS, PREF_ENABLE_DM_AUTO_REFRESH,
|
||||
FLAG_SECURE, TOGGLE_KEYWORD_FILTER, PREF_ENABLE_SENTRY, HIDE_MUTED_REELS, PLAY_IN_BACKGROUND, PREF_SHOWN_COUNT_TOOLTIP})
|
||||
FLAG_SECURE, TOGGLE_KEYWORD_FILTER, PREF_ENABLE_SENTRY, HIDE_MUTED_REELS, PLAY_IN_BACKGROUND,
|
||||
PREF_SHOWN_COUNT_TOOLTIP, PREF_SEARCH_FOCUS_KEYBOARD})
|
||||
public @interface BooleanSettings {}
|
||||
|
||||
@StringDef({PREV_INSTALL_VERSION, BROWSER_UA_CODE, APP_UA_CODE, PREF_ENABLE_DM_AUTO_REFRESH_FREQ_NUMBER})
|
||||
|
@ -10,11 +10,13 @@ import android.util.Patterns;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class TextUtils {
|
||||
// extracted from String class
|
||||
@ -106,4 +108,15 @@ public final class TextUtils {
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
// https://github.com/notslang/instagram-id-to-url-segment
|
||||
public static long shortcodeToId(final String shortcode) {
|
||||
long result = 0L;
|
||||
for (int i = 0; i < shortcode.length() && i < 11; i++){
|
||||
final char c = shortcode.charAt(i);
|
||||
final int k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(c);
|
||||
result = result * 64 + k;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -235,7 +235,7 @@
|
||||
<string name="request_approve">Approve request</string>
|
||||
<string name="request_reject">Reject request</string>
|
||||
<string name="share_public_post">Share this public post to…</string>
|
||||
<string name="share_private_post">This is a private post! Share to those who can view them!</string>
|
||||
<string name="share_private_post">This is a private post! Share to those who can view it.</string>
|
||||
<string name="discover_empty">This category is somehow empty…</string>
|
||||
<string name="update_available">An update is available! (%s)</string>
|
||||
<string name="update_notice">Reminder: If you downloaded from F-Droid, you must update from it! Same applies for GitHub.</string>
|
||||
@ -269,6 +269,7 @@
|
||||
<string name="skip_update_checkbox">Do not show again until next update</string>
|
||||
<string name="version">Version</string>
|
||||
<string name="pref_start_screen">Start screen</string>
|
||||
<string name="pref_search_focus_keyboard" comment="basically bring up the keyboard immediately when someone does search">Show keyboard on search</string>
|
||||
<string name="pref_category_general">General</string>
|
||||
<string name="pref_category_theme">Theme</string>
|
||||
<string name="pref_category_downloads">Downloads</string>
|
||||
@ -505,4 +506,5 @@
|
||||
<string name="no_external_map_app">No Map app found!</string>
|
||||
<string name="click_to_show_full">Click to view full count</string>
|
||||
<string name="no_profile_pic_found">No profile pic found!</string>
|
||||
<string name="swipe_up_confirmation">Are you sure you want to open this link?</string>
|
||||
</resources>
|
||||
|
@ -0,0 +1,28 @@
|
||||
// java.lang.RuntimeException: Method parse in android.net.Uri not mocked.
|
||||
// See http://g.co/androidstudio/not-mocked for details.
|
||||
|
||||
package awais.instagrabber.utils;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import awais.instagrabber.models.IntentModel;
|
||||
import awais.instagrabber.models.enums.IntentModelType;
|
||||
|
||||
class IntentUtilsTest {
|
||||
|
||||
@Test
|
||||
void getIntentFromUrl() {
|
||||
IntentModel intent = IntentUtils.parseUrl("https://instagr.am/austinhuang.me");
|
||||
Assertions.assertEquals(new IntentModel(IntentModelType.USERNAME, "austinhuang.me"), intent);
|
||||
intent = IntentUtils.parseUrl("https://www.instagr.am/_u/austinhuang.me");
|
||||
Assertions.assertEquals(new IntentModel(IntentModelType.USERNAME, "austinhuang.me"), intent);
|
||||
intent = IntentUtils.parseUrl("https://instagram.com/p/BmjKdkxjzO7/");
|
||||
Assertions.assertEquals(new IntentModel(IntentModelType.POST, "BmjKdkxjzO7"), intent);
|
||||
intent = IntentUtils.parseUrl("https://www.instagram.com/explore/tags/metrodemontreal/");
|
||||
Assertions.assertEquals(new IntentModel(IntentModelType.HASHTAG, "metrodemontreal"), intent);
|
||||
intent = IntentUtils.parseUrl("http://www.instagram.com/explore/locations/538444610/abcde");
|
||||
Assertions.assertEquals(new IntentModel(IntentModelType.LOCATION, "538444610"), intent);
|
||||
// todo: reel and igtv test cases that are sfw and preferably n i c e
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package awais.instagrabber.utils;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class TextUtilsTest {
|
||||
|
||||
@org.junit.jupiter.api.Test
|
||||
@Test
|
||||
void testMillisToTimeString() {
|
||||
String timeString = TextUtils.millisToTimeString(18000000);
|
||||
Assertions.assertEquals("05:00:00", timeString);
|
||||
@ -15,4 +16,12 @@ class TextUtilsTest {
|
||||
timeString = TextUtils.millisToTimeString(300000, true);
|
||||
Assertions.assertEquals("00:05:00", timeString);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShortcodeConversion() {
|
||||
long conversion = TextUtils.shortcodeToId("CA0YnOonSfS");
|
||||
Assertions.assertEquals(2320587956892280786L, conversion);
|
||||
conversion = TextUtils.shortcodeToId("B_7n8mblwx6gv1ZaNvA5ZhAs2qslMnRiMMYW1c0");
|
||||
Assertions.assertEquals(2304611322577751162L, conversion);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user