mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-04-03 09:31:34 +00:00
saf cleanup, close #1439
This commit is contained in:
parent
96fd8de879
commit
ad69f7d382
37 changed files with 15 additions and 323 deletions
|
|
@ -66,8 +66,6 @@ import awais.instagrabber.webservices.ServiceCallback;
|
|||
|
||||
public class CollectionPostsFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = "CollectionPostsFragment";
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||
|
||||
private MainActivity fragmentActivity;
|
||||
private FragmentCollectionPostsBinding binding;
|
||||
|
|
@ -76,8 +74,6 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
|
|||
private SavedCollection savedCollection;
|
||||
private ActionMode actionMode;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
private int downloadChildPosition = -1;
|
||||
private CollectionService collectionService;
|
||||
private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_SAVED_POSTS_LAYOUT);
|
||||
private MenuItem deleteMenu, editMenu;
|
||||
|
|
@ -102,12 +98,8 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
|
|||
if (CollectionPostsFragment.this.selectedFeedModels == null) return false;
|
||||
final Context context = getContext();
|
||||
if (context == null) return false;
|
||||
// if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(CollectionPostsFragment.this.selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
// return true;
|
||||
// }
|
||||
// requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE_FOR_SELECTION);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -137,13 +129,7 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
|
|||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
// if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
// return;
|
||||
// }
|
||||
// downloadFeedModel = feedModel;
|
||||
// downloadChildPosition = -1;
|
||||
// requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -375,25 +361,6 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
|
|||
resetToolbar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final boolean granted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && granted) {
|
||||
if (downloadFeedModel == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, downloadFeedModel, downloadChildPosition);
|
||||
downloadFeedModel = null;
|
||||
downloadChildPosition = -1;
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE_FOR_SELECTION && granted) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetToolbar() {
|
||||
fragmentActivity.resetToolbar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout;
|
||||
import androidx.constraintlayout.motion.widget.MotionScene;
|
||||
import androidx.core.content.PermissionChecker;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.NavDirections;
|
||||
|
|
@ -72,14 +71,10 @@ import awais.instagrabber.webservices.StoriesRepository;
|
|||
import awais.instagrabber.webservices.TagsService;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
||||
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = "HashTagFragment";
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||
|
||||
public static final String ARG_HASHTAG = "hashtag";
|
||||
|
||||
|
|
@ -98,8 +93,6 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
private GraphQLRepository graphQLRepository;
|
||||
private boolean storiesFetching;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
private int downloadChildPosition = -1;
|
||||
private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_HASHTAG_POSTS_LAYOUT);
|
||||
private LayoutHashtagDetailsBinding hashtagDetailsBinding;
|
||||
|
||||
|
|
@ -123,12 +116,8 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
if (HashTagFragment.this.selectedFeedModels == null) return false;
|
||||
final Context context = getContext();
|
||||
if (context == null) return false;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(HashTagFragment.this.selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
return true;
|
||||
}
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE_FOR_SELECTION);
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(HashTagFragment.this.selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -159,13 +148,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
return;
|
||||
}
|
||||
downloadFeedModel = feedModel;
|
||||
downloadChildPosition = childPosition;
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -349,25 +332,6 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final boolean granted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && granted) {
|
||||
if (downloadFeedModel == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, downloadFeedModel, downloadChildPosition);
|
||||
downloadFeedModel = null;
|
||||
downloadChildPosition = -1;
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE_FOR_SELECTION && granted) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (getArguments() == null) return;
|
||||
final HashTagFragmentArgs fragmentArgs = HashTagFragmentArgs.fromBundle(getArguments());
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout;
|
||||
import androidx.constraintlayout.motion.widget.MotionScene;
|
||||
import androidx.core.content.PermissionChecker;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.NavDirections;
|
||||
|
|
@ -68,14 +67,10 @@ import awais.instagrabber.webservices.ServiceCallback;
|
|||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
||||
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = "LocationFragment";
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||
|
||||
private MainActivity fragmentActivity;
|
||||
private FragmentLocationBinding binding;
|
||||
|
|
@ -92,8 +87,6 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
private boolean isLoggedIn;
|
||||
private boolean storiesFetching;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
private int downloadChildPosition = -1;
|
||||
private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_LOCATION_POSTS_LAYOUT);
|
||||
private LayoutLocationDetailsBinding locationDetailsBinding;
|
||||
|
||||
|
|
@ -117,12 +110,9 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
if (LocationFragment.this.selectedFeedModels == null) return false;
|
||||
final Context context = getContext();
|
||||
if (context == null) return false;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(LocationFragment.this.selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
return true;
|
||||
}
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE_FOR_SELECTION);
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(LocationFragment.this.selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -152,13 +142,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
return;
|
||||
}
|
||||
downloadFeedModel = feedModel;
|
||||
downloadChildPosition = childPosition;
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -344,25 +328,6 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final boolean granted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && granted) {
|
||||
if (downloadFeedModel == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, downloadFeedModel, downloadChildPosition);
|
||||
downloadFeedModel = null;
|
||||
downloadChildPosition = -1;
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE_FOR_SELECTION && granted) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (getArguments() == null) return;
|
||||
final LocationFragmentArgs fragmentArgs = LocationFragmentArgs.fromBundle(getArguments());
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import androidx.appcompat.widget.PopupMenu;
|
|||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.appcompat.widget.TooltipCompat;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.PermissionChecker;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
|
@ -105,10 +104,8 @@ import awais.instagrabber.utils.TextUtils;
|
|||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.viewmodels.PostViewV2ViewModel;
|
||||
|
||||
//import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
||||
import static awais.instagrabber.fragments.HashTagFragment.ARG_HASHTAG;
|
||||
import static awais.instagrabber.fragments.settings.PreferenceKeys.PREF_SHOWN_COUNT_TOOLTIP;
|
||||
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
public class PostViewV2Fragment extends Fragment implements EditTextDialogFragment.EditTextDialogFragmentCallback {
|
||||
|
|
@ -116,7 +113,6 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
|||
// private static final int DETAILS_HIDE_DELAY_MILLIS = 2000;
|
||||
public static final String ARG_MEDIA = "media";
|
||||
public static final String ARG_SLIDER_POSITION = "position";
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
|
||||
private DialogPostViewBinding binding;
|
||||
private Context context;
|
||||
|
|
@ -281,16 +277,6 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, viewModel.getMedia(), sliderPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
final Bundle arguments = getArguments();
|
||||
if (arguments == null) {
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ import static awais.instagrabber.utils.Utils.settingsHelper;
|
|||
|
||||
public final class SavedViewerFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = SavedViewerFragment.class.getSimpleName();
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||
|
||||
private FragmentSavedBinding binding;
|
||||
private String username;
|
||||
|
|
@ -61,8 +59,6 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
|
|||
private boolean isLoggedIn, shouldRefresh = true;
|
||||
private PostItemType type;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
private int downloadChildPosition = -1;
|
||||
private PostsLayoutPreferences layoutPreferences;
|
||||
|
||||
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
|
||||
|
|
@ -85,12 +81,8 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
|
|||
if (SavedViewerFragment.this.selectedFeedModels == null) return false;
|
||||
final Context context = getContext();
|
||||
if (context == null) return false;
|
||||
// if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(SavedViewerFragment.this.selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
// return true;
|
||||
// }
|
||||
// requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE_FOR_SELECTION);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -120,13 +112,7 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
|
|||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
// if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
// return;
|
||||
// }
|
||||
// downloadFeedModel = feedModel;
|
||||
// downloadChildPosition = childPosition;
|
||||
// requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -306,25 +292,6 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final boolean granted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && granted) {
|
||||
if (downloadFeedModel == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, downloadFeedModel, downloadChildPosition);
|
||||
downloadFeedModel = null;
|
||||
downloadChildPosition = -1;
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE_FOR_SELECTION && granted) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void setTitle() {
|
||||
final ActionBar actionBar = fragmentActivity.getSupportActionBar();
|
||||
if (actionBar == null) return;
|
||||
|
|
|
|||
|
|
@ -209,10 +209,7 @@ public class StoryViewerFragment extends Fragment {
|
|||
if (context == null) return false;
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_download) {
|
||||
if (ContextCompat.checkSelfPermission(context, DownloadUtils.PERMS[0]) == PackageManager.PERMISSION_GRANTED)
|
||||
downloadStory();
|
||||
else
|
||||
ActivityCompat.requestPermissions(requireActivity(), DownloadUtils.PERMS, 8020);
|
||||
downloadStory();
|
||||
return true;
|
||||
}
|
||||
if (itemId == R.id.action_dms) {
|
||||
|
|
@ -263,13 +260,6 @@ public class StoryViewerFragment extends Fragment {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 8020 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
||||
downloadStory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
|
|
|||
|
|
@ -61,8 +61,6 @@ import awais.instagrabber.webservices.DiscoverService;
|
|||
|
||||
public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = TopicPostsFragment.class.getSimpleName();
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||
|
||||
private MainActivity fragmentActivity;
|
||||
private FragmentTopicPostsBinding binding;
|
||||
|
|
@ -71,8 +69,6 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
|
|||
private TopicCluster topicCluster;
|
||||
private ActionMode actionMode;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
private int downloadChildPosition = -1;
|
||||
private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_TOPIC_POSTS_LAYOUT);
|
||||
|
||||
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) {
|
||||
|
|
@ -95,12 +91,9 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
|
|||
if (TopicPostsFragment.this.selectedFeedModels == null) return false;
|
||||
final Context context = getContext();
|
||||
if (context == null) return false;
|
||||
// if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(TopicPostsFragment.this.selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
return true;
|
||||
// }
|
||||
// requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE_FOR_SELECTION);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -130,13 +123,7 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
|
|||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
// if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
// return;
|
||||
// }
|
||||
// downloadFeedModel = feedModel;
|
||||
// downloadChildPosition = -1;
|
||||
// requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -299,25 +286,6 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
|
|||
resetToolbar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final boolean granted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && granted) {
|
||||
if (downloadFeedModel == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, downloadFeedModel, downloadChildPosition);
|
||||
downloadFeedModel = null;
|
||||
downloadChildPosition = -1;
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE_FOR_SELECTION && granted) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(selectedFeedModels));
|
||||
binding.posts.endSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetToolbar() {
|
||||
fragmentActivity.resetToolbar();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@ import awais.instagrabber.viewmodels.factories.DirectThreadViewModelFactory;
|
|||
public class DirectMessageThreadFragment extends Fragment implements DirectReactionsAdapter.OnReactionClickListener,
|
||||
EmojiPicker.OnEmojiClickListener {
|
||||
private static final String TAG = DirectMessageThreadFragment.class.getSimpleName();
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int AUDIO_RECORD_PERM_REQUEST_CODE = 1000;
|
||||
private static final int CAMERA_REQUEST_CODE = 200;
|
||||
private static final String TRANSLATION_Y = "translationY";
|
||||
|
|
@ -490,17 +489,12 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
if (tempMedia == null) return;
|
||||
downloadItem(context, tempMedia);
|
||||
return;
|
||||
}
|
||||
if (requestCode == AUDIO_RECORD_PERM_REQUEST_CODE) {
|
||||
if (PermissionUtils.hasAudioRecordPerms(context)) {
|
||||
Toast.makeText(context, "You can send voice messages now!", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Toast.makeText(context, "Require RECORD_AUDIO and WRITE_EXTERNAL_STORAGE permissions", Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(context, "Require RECORD_AUDIO permission", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1408,13 +1402,8 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
// if (ContextCompat.checkSelfPermission(context, DownloadUtils.PERMS[0]) == PackageManager.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, media);
|
||||
Toast.makeText(context, R.string.downloader_downloading_media, Toast.LENGTH_SHORT).show();
|
||||
// return;
|
||||
// }
|
||||
// tempMedia = media;
|
||||
// requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout;
|
||||
import androidx.constraintlayout.motion.widget.MotionScene;
|
||||
import androidx.core.content.PermissionChecker;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.NavController;
|
||||
|
|
@ -57,13 +56,8 @@ import awais.instagrabber.viewmodels.FeedStoriesViewModel;
|
|||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
||||
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
|
||||
|
||||
public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = "FeedFragment";
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||
|
||||
private MainActivity fragmentActivity;
|
||||
private MotionLayout root;
|
||||
|
|
@ -75,8 +69,6 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
private boolean storiesFetching;
|
||||
private ActionMode actionMode;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
private int downloadChildPosition = -1;
|
||||
private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_POSTS_LAYOUT);
|
||||
private RecyclerView storiesRecyclerView;
|
||||
private MenuItem storyListMenu;
|
||||
|
|
@ -129,13 +121,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
return;
|
||||
}
|
||||
downloadFeedModel = feedModel;
|
||||
downloadChildPosition = childPosition;
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -218,12 +204,8 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
if (FeedFragment.this.selectedFeedModels == null) return false;
|
||||
final Context context = getContext();
|
||||
if (context == null) return false;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(FeedFragment.this.selectedFeedModels));
|
||||
binding.feedRecyclerView.endSelection();
|
||||
return true;
|
||||
}
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE_FOR_SELECTION);
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(FeedFragment.this.selectedFeedModels));
|
||||
binding.feedRecyclerView.endSelection();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -359,29 +341,6 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (!granted) {
|
||||
Toast.makeText(context, R.string.download_permission, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && granted) {
|
||||
if (downloadFeedModel == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, downloadFeedModel, downloadChildPosition);
|
||||
downloadFeedModel = null;
|
||||
downloadChildPosition = -1;
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE_FOR_SELECTION && granted) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(selectedFeedModels));
|
||||
binding.feedRecyclerView.endSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupFeed() {
|
||||
binding.feedRecyclerView.setViewModelStoreOwner(this)
|
||||
.setLifeCycleOwner(this)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import androidx.appcompat.app.AlertDialog;
|
|||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout;
|
||||
import androidx.constraintlayout.motion.widget.MotionScene;
|
||||
import androidx.core.content.PermissionChecker;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
|
@ -105,14 +104,10 @@ import awais.instagrabber.webservices.StoriesRepository;
|
|||
import awais.instagrabber.webservices.UserRepository;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
||||
import static awais.instagrabber.fragments.HashTagFragment.ARG_HASHTAG;
|
||||
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
|
||||
|
||||
public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static final String TAG = "ProfileFragment";
|
||||
private static final int STORAGE_PERM_REQUEST_CODE = 8020;
|
||||
private static final int STORAGE_PERM_REQUEST_CODE_FOR_SELECTION = 8030;
|
||||
|
||||
private MainActivity fragmentActivity;
|
||||
private MotionLayout root;
|
||||
|
|
@ -139,8 +134,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
private boolean accountIsUpdated = false;
|
||||
private boolean postsSetupDone = false;
|
||||
private Set<Media> selectedFeedModels;
|
||||
private Media downloadFeedModel;
|
||||
private int downloadChildPosition = -1;
|
||||
private long myId;
|
||||
private PostsLayoutPreferences layoutPreferences = Utils.getPostsLayoutPreferences(Constants.PREF_PROFILE_POSTS_LAYOUT);
|
||||
private LayoutProfileDetailsBinding profileDetailsBinding;
|
||||
|
|
@ -199,12 +192,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
if (ProfileFragment.this.selectedFeedModels == null) return false;
|
||||
final Context context = getContext();
|
||||
if (context == null) return false;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(ProfileFragment.this.selectedFeedModels));
|
||||
binding.postsRecyclerView.endSelection();
|
||||
return true;
|
||||
}
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE_FOR_SELECTION);
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(ProfileFragment.this.selectedFeedModels));
|
||||
binding.postsRecyclerView.endSelection();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -235,13 +224,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (checkSelfPermission(context, WRITE_PERMISSION) == PermissionChecker.PERMISSION_GRANTED) {
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
return;
|
||||
}
|
||||
downloadFeedModel = feedModel;
|
||||
downloadChildPosition = childPosition;
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -638,25 +621,6 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
final boolean granted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
final Context context = getContext();
|
||||
if (context == null) return;
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE && granted) {
|
||||
if (downloadFeedModel == null) return;
|
||||
DownloadUtils.showDownloadDialog(context, downloadFeedModel, downloadChildPosition);
|
||||
downloadFeedModel = null;
|
||||
downloadChildPosition = -1;
|
||||
return;
|
||||
}
|
||||
if (requestCode == STORAGE_PERM_REQUEST_CODE_FOR_SELECTION && granted) {
|
||||
DownloadUtils.download(context, ImmutableList.copyOf(selectedFeedModels));
|
||||
binding.postsRecyclerView.endSelection();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
disableDm = !Utils.isNavRootInCurrentTabs("direct_messages_nav_graph");
|
||||
if (getArguments() != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue