mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Implement onActivityResult() in map fragment
This commit is contained in:
parent
fe430699b4
commit
da7916069f
3 changed files with 26 additions and 5 deletions
|
|
@ -77,10 +77,11 @@ public class ContributionController {
|
|||
//FIXME: Starts gallery (opens Google Photos)
|
||||
Intent pickImageIntent = new Intent(ACTION_GET_CONTENT);
|
||||
pickImageIntent.setType("image/*");
|
||||
Timber.d("startGalleryPick() called with pickImageIntent");
|
||||
fragment.startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY);
|
||||
}
|
||||
|
||||
void handleImagePicked(int requestCode, Intent data) {
|
||||
public void handleImagePicked(int requestCode, Intent data) {
|
||||
FragmentActivity activity = fragment.getActivity();
|
||||
Intent shareIntent = new Intent(activity, ShareActivity.class);
|
||||
shareIntent.setAction(ACTION_SEND);
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ class DirectUpload {
|
|||
private ContributionController controller;
|
||||
private Fragment fragment;
|
||||
|
||||
DirectUpload(String title, String desc, Fragment fragment) {
|
||||
DirectUpload(String title, String desc, Fragment fragment, ContributionController controller) {
|
||||
this.title = title;
|
||||
this.desc = desc;
|
||||
this.fragment = fragment;
|
||||
controller = new ContributionController(fragment);
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
void storeSharedPrefs() {
|
||||
|
|
@ -74,6 +74,6 @@ class DirectUpload {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO: Need to call onActivityResult() to handle the image picked
|
||||
//TODO: Handle onRequestPermissionsResult
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,12 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.contributions.ContributionController;
|
||||
import fr.free.nrw.commons.utils.UriDeserializer;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
||||
|
||||
private MapView mapView;
|
||||
|
|
@ -78,6 +81,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
private Animation fab_close;
|
||||
private Animation fab_open;
|
||||
private Animation rotate_forward;
|
||||
private ContributionController controller;
|
||||
|
||||
private Place place;
|
||||
private Marker selected;
|
||||
|
|
@ -405,12 +409,28 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
fabGallery.setOnClickListener(view -> {
|
||||
Timber.d("Image title: " + place.getName() + "Image desc: " + place.getLongDescription());
|
||||
|
||||
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this);
|
||||
controller = new ContributionController(this);
|
||||
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller);
|
||||
directUpload.storeSharedPrefs();
|
||||
directUpload.initiateGalleryUpload();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
//FIXME: must get the file data for Google Photos when receive the intent answer, in the onActivityResult method
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (resultCode == RESULT_OK) {
|
||||
Timber.d("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
|
||||
requestCode, resultCode, data);
|
||||
controller.handleImagePicked(requestCode, data);
|
||||
} else {
|
||||
Timber.e("OnActivityResult() parameters: Req code: %d Result code: %d Data: %s",
|
||||
requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void openWebView(Uri link) {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, link);
|
||||
startActivity(browserIntent);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue