mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Use dexter for requesting storage permissions (#2258)
* Use dexter for requesting storage permissions * minor changes * Fix minor issue
This commit is contained in:
parent
2ea6bd7f65
commit
a48a09a785
13 changed files with 149 additions and 408 deletions
|
|
@ -47,6 +47,7 @@ public class BookmarkLocationsFragment extends DaggerFragment {
|
|||
@Inject
|
||||
BookmarkLocationsController controller;
|
||||
@Inject @Named("direct_nearby_upload_prefs") SharedPreferences directPrefs;
|
||||
@Inject @Named("default_preferences") SharedPreferences defaultPrefs;
|
||||
private NearbyAdapterFactory adapterFactory;
|
||||
private ContributionController contributionController;
|
||||
|
||||
|
|
@ -66,7 +67,7 @@ public class BookmarkLocationsFragment extends DaggerFragment {
|
|||
) {
|
||||
View v = inflater.inflate(R.layout.fragment_bookmarks_locations, container, false);
|
||||
ButterKnife.bind(this, v);
|
||||
contributionController = new ContributionController(this);
|
||||
contributionController = new ContributionController(this, defaultPrefs);
|
||||
adapterFactory = new NearbyAdapterFactory(this, contributionController);
|
||||
return v;
|
||||
}
|
||||
|
|
@ -100,30 +101,6 @@ public class BookmarkLocationsFragment extends DaggerFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
Timber.d("onRequestPermissionsResult: req code = " + " perm = " + permissions + " grant =" + grantResults);
|
||||
|
||||
switch (requestCode) {
|
||||
// 4 = "Read external storage" allowed when gallery selected
|
||||
case 4: {
|
||||
if (grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED) {
|
||||
Timber.d("Call controller.startGalleryPick()");
|
||||
contributionController.startGalleryPick();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// 5 = "Write external storage" allowed when camera selected
|
||||
case 5: {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Timber.d("Call controller.startCameraCapture()");
|
||||
contributionController.startCameraCapture();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue