36
36
import fr .free .nrw .commons .edit .EditActivity ;
37
37
import fr .free .nrw .commons .contributions .MainActivity ;
38
38
import fr .free .nrw .commons .filepicker .UploadableFile ;
39
+ import fr .free .nrw .commons .kvstore .BasicKvStore ;
39
40
import fr .free .nrw .commons .kvstore .JsonKvStore ;
40
41
import fr .free .nrw .commons .location .LatLng ;
41
42
import fr .free .nrw .commons .nearby .Place ;
@@ -251,7 +252,10 @@ private void attachImageViewScaleChangeListener() {
251
252
photoViewBackgroundImage .setOnScaleChangeListener (
252
253
(scaleFactor , focusX , focusY ) -> {
253
254
//Whenever the uses plays with the image, lets collapse the media detail container
254
- expandCollapseLlMediaDetail (false );
255
+ //only if it is not already collapsed, which resolves flickering of arrow
256
+ if (isExpanded ) {
257
+ expandCollapseLlMediaDetail (false );
258
+ }
255
259
});
256
260
}
257
261
@@ -306,31 +310,35 @@ public void onEditButtonClicked() {
306
310
@ Override
307
311
public void showSimilarImageFragment (String originalFilePath , String possibleFilePath ,
308
312
ImageCoordinates similarImageCoordinates ) {
309
- SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment ();
310
- newFragment .setCallback (new SimilarImageDialogFragment .Callback () {
311
- @ Override
312
- public void onPositiveResponse () {
313
- Timber .d ("positive response from similar image fragment" );
314
- presenter .useSimilarPictureCoordinates (similarImageCoordinates , callback .getIndexInViewFlipper (UploadMediaDetailFragment .this ));
315
-
316
- // set the description text when user selects to use coordinate from the other image
317
- // which was taken within 20s
318
- // fixing: https://github.com/commons-app/apps-android-commons/issues/4700
319
- uploadMediaDetailAdapter .getItems ().get (0 ).setDescriptionText (
320
- getString (R .string .similar_coordinate_description_auto_set ));
321
- updateMediaDetails (uploadMediaDetailAdapter .getItems ());
322
- }
313
+ BasicKvStore basicKvStore = new BasicKvStore (getActivity (), "IsAnyImageCancelled" );
314
+ if (!basicKvStore .getBoolean ("IsAnyImageCancelled" , false )) {
315
+ SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment ();
316
+ newFragment .setCallback (new SimilarImageDialogFragment .Callback () {
317
+ @ Override
318
+ public void onPositiveResponse () {
319
+ Timber .d ("positive response from similar image fragment" );
320
+ presenter .useSimilarPictureCoordinates (similarImageCoordinates ,
321
+ callback .getIndexInViewFlipper (UploadMediaDetailFragment .this ));
322
+
323
+ // set the description text when user selects to use coordinate from the other image
324
+ // which was taken within 120s
325
+ // fixing: https://github.com/commons-app/apps-android-commons/issues/4700
326
+ uploadMediaDetailAdapter .getItems ().get (0 ).setDescriptionText (
327
+ getString (R .string .similar_coordinate_description_auto_set ));
328
+ updateMediaDetails (uploadMediaDetailAdapter .getItems ());
329
+ }
323
330
324
- @ Override
325
- public void onNegativeResponse () {
326
- Timber .d ("negative response from similar image fragment" );
327
- }
328
- });
329
- Bundle args = new Bundle ();
330
- args .putString ("originalImagePath" , originalFilePath );
331
- args .putString ("possibleImagePath" , possibleFilePath );
332
- newFragment .setArguments (args );
333
- newFragment .show (getChildFragmentManager (), "dialog" );
331
+ @ Override
332
+ public void onNegativeResponse () {
333
+ Timber .d ("negative response from similar image fragment" );
334
+ }
335
+ });
336
+ Bundle args = new Bundle ();
337
+ args .putString ("originalImagePath" , originalFilePath );
338
+ args .putString ("possibleImagePath" , possibleFilePath );
339
+ newFragment .setArguments (args );
340
+ newFragment .show (getChildFragmentManager (), "dialog" );
341
+ }
334
342
}
335
343
336
344
@ Override
@@ -455,7 +463,8 @@ public void showDuplicatePicturePopup(UploadItem uploadItem) {
455
463
false );
456
464
} else {
457
465
uploadItem .setImageQuality (ImageUtils .IMAGE_KEEP );
458
- onNextButtonClicked ();
466
+ // Calling below, instead of onNextButtonClicked() to not show locationDialog twice
467
+ onImageValidationSuccess ();
459
468
}
460
469
}
461
470
@@ -478,7 +487,11 @@ public void showBadImagePopup(Integer errorCode,
478
487
479
488
// validate image only when same file name error does not occur
480
489
// show the same file name error if exists.
481
- if ((errorCode & FILE_NAME_EXISTS ) == 0 ) {
490
+ // If image with same file name exists check the bit in errorCode is set or not
491
+ if ((errorCode & FILE_NAME_EXISTS ) != 0 ) {
492
+ Timber .d ("Trying to show duplicate picture popup" );
493
+ showDuplicatePicturePopup (uploadItem );
494
+ } else {
482
495
uploadItem .setImageQuality (ImageUtils .IMAGE_KEEP );
483
496
onImageValidationSuccess ();
484
497
}
0 commit comments