|
7 | 7 | import android.app.Activity; |
8 | 8 | import android.content.Context; |
9 | 9 | import android.content.Intent; |
| 10 | +import android.util.Log; |
10 | 11 | import androidx.annotation.NonNull; |
11 | 12 | import fr.free.nrw.commons.R; |
12 | 13 | import fr.free.nrw.commons.filepicker.DefaultCallback; |
13 | 14 | import fr.free.nrw.commons.filepicker.FilePicker; |
| 15 | +import fr.free.nrw.commons.filepicker.FilePicker.ImageSource; |
14 | 16 | import fr.free.nrw.commons.filepicker.UploadableFile; |
15 | 17 | import fr.free.nrw.commons.kvstore.JsonKvStore; |
16 | 18 | import fr.free.nrw.commons.nearby.Place; |
@@ -95,6 +97,13 @@ private void initiateCameraUpload(Activity activity) { |
95 | 97 | */ |
96 | 98 | public void handleActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { |
97 | 99 | FilePicker.handleActivityResult(requestCode, resultCode, data, activity, new DefaultCallback() { |
| 100 | + |
| 101 | + @Override |
| 102 | + public void onCanceled(final ImageSource source, final int type) { |
| 103 | + super.onCanceled(source, type); |
| 104 | + defaultKvStore.remove(PLACE_OBJECT); |
| 105 | + } |
| 106 | + |
98 | 107 | @Override |
99 | 108 | public void onImagePickerError(Exception e, FilePicker.ImageSource source, int type) { |
100 | 109 | ViewUtil.showShortToast(activity, R.string.error_occurred_in_picking_images); |
@@ -123,6 +132,7 @@ private Intent handleImagesPicked(Context context, |
123 | 132 | shareIntent.setAction(ACTION_INTERNAL_UPLOADS); |
124 | 133 | shareIntent.putParcelableArrayListExtra(EXTRA_FILES, new ArrayList<>(imagesFiles)); |
125 | 134 | Place place = defaultKvStore.getJson(PLACE_OBJECT, Place.class); |
| 135 | + |
126 | 136 | if (place != null) { |
127 | 137 | shareIntent.putExtra(PLACE_OBJECT, place); |
128 | 138 | } |
|
0 commit comments