Fixed #4793 : Remove the need to tap "Next" again (#4833)

* Fixed #4793 : Remove the need to tap "Next" again

* Fixed #4793 : Remove the need to tap "Next" again

* Fixed #4793 : Remove the need to tap "Next" again, Added Changes
This commit is contained in:
Arin Modi 2022-02-19 13:14:44 +05:30 committed by GitHub
parent e26f6144f3
commit 68a0400b9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 2 deletions

View file

@ -95,6 +95,12 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
private boolean isExpanded = true;
/**
* True if location is added via the "missing location" popup dialog (which appears after tapping
* "Next" if the picture has no geographical coordinates).
*/
private boolean isMissingLocationDialog;
/**
* showNearbyFound will be true, if any nearby location found that needs pictures and the nearby popup is yet to be shown
* Used to show and check if the nearby found popup is already shown
@ -483,6 +489,14 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
final double zoom = cameraPosition.zoom;
editLocation(latitude, longitude,zoom);
/*
If isMissingLocationDialog is true, it means that the user has already tapped the
"Next" button, so go directly to the next step.
*/
if(isMissingLocationDialog){
isMissingLocationDialog = false;
onNextButtonClicked();
}
}
}
}
@ -515,6 +529,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
*/
@Override
public void displayAddLocationDialog(final Runnable onSkipClicked) {
isMissingLocationDialog = true;
DialogUtil.showAlertDialog(Objects.requireNonNull(getActivity()),
getString(R.string.no_location_found_title),
getString(R.string.no_location_found_message),

View file

@ -359,8 +359,8 @@ class UploadMediaDetailFragmentUnitTest {
@Test
@Throws(Exception::class)
fun testOnActivityResult() {
Shadows.shadowOf(Looper.getMainLooper()).idle()
fun testOnActivityResultOnMapIconClicked() {
shadowOf(Looper.getMainLooper()).idle()
Mockito.mock(LocationPicker::class.java)
val intent = Mockito.mock(Intent::class.java)
val cameraPosition = Mockito.mock(CameraPosition::class.java)
@ -374,6 +374,29 @@ class UploadMediaDetailFragmentUnitTest {
`when`(latLng.longitude).thenReturn(0.0)
`when`(uploadItem.gpsCoords).thenReturn(imageCoordinates)
fragment.onActivityResult(1211, Activity.RESULT_OK, intent)
Mockito.verify(presenter, Mockito.times(0)).verifyImageQuality(0)
}
@Test
@Throws(Exception::class)
fun testOnActivityResultAddLocationDialog() {
shadowOf(Looper.getMainLooper()).idle()
Mockito.mock(LocationPicker::class.java)
val intent = Mockito.mock(Intent::class.java)
val cameraPosition = Mockito.mock(CameraPosition::class.java)
val latLng = Mockito.mock(LatLng::class.java)
Whitebox.setInternalState(cameraPosition, "target", latLng)
Whitebox.setInternalState(fragment, "editableUploadItem", uploadItem)
Whitebox.setInternalState(fragment,"isMissingLocationDialog",true)
Whitebox.setInternalState(fragment, "presenter", presenter)
`when`(LocationPicker.getCameraPosition(intent)).thenReturn(cameraPosition)
`when`(latLng.latitude).thenReturn(0.0)
`when`(latLng.longitude).thenReturn(0.0)
`when`(uploadItem.gpsCoords).thenReturn(imageCoordinates)
fragment.onActivityResult(1211, Activity.RESULT_OK, intent)
Mockito.verify(presenter, Mockito.times(1)).verifyImageQuality(0)
}
@Test