mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Implement onActivityResult() in map fragment
This commit is contained in:
		
							parent
							
								
									792cc2c4c7
								
							
						
					
					
						commit
						3dde0319a0
					
				
					 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 | ||||
| } | ||||
|  |  | |||
|  | @ -41,9 +41,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; | ||||
|  | @ -77,6 +80,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; | ||||
| 
 | ||||
|  | @ -390,12 +394,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
	
	 misaochan
						misaochan