Complete initiateDirectUpload()

This commit is contained in:
misaochan 2018-01-01 20:23:51 +10:00
parent da5e20a547
commit 946c6c740d
2 changed files with 9 additions and 11 deletions

View file

@ -49,8 +49,7 @@ class DirectUpload {
Activity activity = (Activity) context; Activity activity = (Activity) context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(activity, READ_EXTERNAL_STORAGE) if (ContextCompat.checkSelfPermission(activity, READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
!= PERMISSION_GRANTED) {
if (activity.shouldShowRequestPermissionRationale(READ_EXTERNAL_STORAGE)) { if (activity.shouldShowRequestPermissionRationale(READ_EXTERNAL_STORAGE)) {
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity)
.setMessage(activity.getString(R.string.read_storage_permission_rationale)) .setMessage(activity.getString(R.string.read_storage_permission_rationale))
@ -64,15 +63,13 @@ class DirectUpload {
} else { } else {
activity.requestPermissions(new String[]{READ_EXTERNAL_STORAGE}, activity.requestPermissions(new String[]{READ_EXTERNAL_STORAGE},
1); 1);
}
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an } else {
// app-defined int constant. The callback method gets the controller.startGalleryPick();
// result of the request.
} }
} }
else { else {
controller.startGalleryPick(); controller.startGalleryPick();
return true;
} }
} }
} }

View file

@ -386,8 +386,9 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
//TODO: Change this to activate camera upload (see ContributionsListFragment). Insert shared preference. //TODO: Change this to activate camera upload (see ContributionsListFragment). Insert shared preference.
Timber.d("Image title: " + place.getName() + "Image desc: " + place.getLongDescription()); Timber.d("Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription()); DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this);
directUpload.storeSharedPrefs(getActivity()); directUpload.storeSharedPrefs(getActivity());
directUpload.initiateUpload(getActivity());
}); });