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 ;
40
39
import fr .free .nrw .commons .kvstore .JsonKvStore ;
41
40
import fr .free .nrw .commons .location .LatLng ;
42
41
import fr .free .nrw .commons .nearby .Place ;
@@ -70,6 +69,11 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
70
69
private static final int REQUEST_CODE_FOR_EDIT_ACTIVITY = 1212 ;
71
70
private static final int REQUEST_CODE_FOR_VOICE_INPUT = 1213 ;
72
71
72
+ /**
73
+ * Stores the rotation angle of the image in degrees.
74
+ */
75
+ private int rotation = 0 ;
76
+
73
77
/**
74
78
* A key for applicationKvStore. By this key we can retrieve the location of last UploadItem ex.
75
79
* 12.3433,54.78897 from applicationKvStore.
@@ -196,10 +200,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
196
200
}
197
201
198
202
if (savedInstanceState !=null ){
199
- if (uploadMediaDetailAdapter .getItems ().size ()==0 ){
200
- uploadMediaDetailAdapter .setItems (savedInstanceState .getParcelableArrayList (UPLOAD_MEDIA_DETAILS ));
201
- presenter .setUploadMediaDetails (uploadMediaDetailAdapter .getItems (), callback .getIndexInViewFlipper (this ));
202
- }
203
+ if (uploadMediaDetailAdapter .getItems ().size ()==0 ){
204
+ uploadMediaDetailAdapter .setItems (savedInstanceState .getParcelableArrayList (UPLOAD_MEDIA_DETAILS ));
205
+ presenter .setUploadMediaDetails (uploadMediaDetailAdapter .getItems (), callback .getIndexInViewFlipper (this ));
206
+ }
203
207
}
204
208
205
209
}
@@ -223,7 +227,7 @@ private void init() {
223
227
224
228
// If the image EXIF data contains the location, show the map icon with a green tick
225
229
if (inAppPictureLocation != null ||
226
- (uploadableFile != null && uploadableFile .hasLocation ())) {
230
+ (uploadableFile != null && uploadableFile .hasLocation ())) {
227
231
Drawable mapTick = getResources ().getDrawable (R .drawable .ic_map_available_20dp );
228
232
locationImageView .setImageDrawable (mapTick );
229
233
locationTextView .setText (R .string .edit_location );
@@ -252,10 +256,7 @@ private void attachImageViewScaleChangeListener() {
252
256
photoViewBackgroundImage .setOnScaleChangeListener (
253
257
(scaleFactor , focusX , focusY ) -> {
254
258
//Whenever the uses plays with the image, lets collapse the media detail container
255
- //only if it is not already collapsed, which resolves flickering of arrow
256
- if (isExpanded ) {
257
- expandCollapseLlMediaDetail (false );
258
- }
259
+ expandCollapseLlMediaDetail (false );
259
260
});
260
261
}
261
262
@@ -310,35 +311,31 @@ public void onEditButtonClicked() {
310
311
@ Override
311
312
public void showSimilarImageFragment (String originalFilePath , String possibleFilePath ,
312
313
ImageCoordinates similarImageCoordinates ) {
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
- }
314
+ SimilarImageDialogFragment newFragment = new SimilarImageDialogFragment ();
315
+ newFragment .setCallback (new SimilarImageDialogFragment .Callback () {
316
+ @ Override
317
+ public void onPositiveResponse () {
318
+ Timber .d ("positive response from similar image fragment" );
319
+ presenter .useSimilarPictureCoordinates (similarImageCoordinates , callback .getIndexInViewFlipper (UploadMediaDetailFragment .this ));
320
+
321
+ // set the description text when user selects to use coordinate from the other image
322
+ // which was taken within 20s
323
+ // fixing: https://github.com/commons-app/apps-android-commons/issues/4700
324
+ uploadMediaDetailAdapter .getItems ().get (0 ).setDescriptionText (
325
+ getString (R .string .similar_coordinate_description_auto_set ));
326
+ updateMediaDetails (uploadMediaDetailAdapter .getItems ());
327
+ }
330
328
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
- }
329
+ @ Override
330
+ public void onNegativeResponse () {
331
+ Timber .d ("negative response from similar image fragment" );
332
+ }
333
+ });
334
+ Bundle args = new Bundle ();
335
+ args .putString ("originalImagePath" , originalFilePath );
336
+ args .putString ("possibleImagePath" , possibleFilePath );
337
+ newFragment .setArguments (args );
338
+ newFragment .show (getChildFragmentManager (), "dialog" );
342
339
}
343
340
344
341
@ Override
@@ -463,8 +460,7 @@ public void showDuplicatePicturePopup(UploadItem uploadItem) {
463
460
false );
464
461
} else {
465
462
uploadItem .setImageQuality (ImageUtils .IMAGE_KEEP );
466
- // Calling below, instead of onNextButtonClicked() to not show locationDialog twice
467
- onImageValidationSuccess ();
463
+ onNextButtonClicked ();
468
464
}
469
465
}
470
466
@@ -487,11 +483,7 @@ public void showBadImagePopup(Integer errorCode,
487
483
488
484
// validate image only when same file name error does not occur
489
485
// show the same file name error if exists.
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 {
486
+ if ((errorCode & FILE_NAME_EXISTS ) == 0 ) {
495
487
uploadItem .setImageQuality (ImageUtils .IMAGE_KEEP );
496
488
onImageValidationSuccess ();
497
489
}
@@ -530,6 +522,7 @@ public void showEditActivity(UploadItem uploadItem) {
530
522
editableUploadItem = uploadItem ;
531
523
Intent intent = new Intent (getContext (), EditActivity .class );
532
524
intent .putExtra ("image" , uploadableFile .getFilePath ().toString ());
525
+ intent .putExtra ("rotation" ,rotation );
533
526
startActivityForResult (intent , REQUEST_CODE_FOR_EDIT_ACTIVITY );
534
527
}
535
528
@@ -615,6 +608,7 @@ public void onActivityResult(final int requestCode, final int resultCode,
615
608
}
616
609
if (requestCode == REQUEST_CODE_FOR_EDIT_ACTIVITY && resultCode == RESULT_OK ) {
617
610
String result = data .getStringExtra ("editedImageFilePath" );
611
+ rotation = data .getIntExtra ("editedImageRotation" ,0 );
618
612
619
613
if (Objects .equals (result , "Error" )) {
620
614
Timber .e ("Error in rotating image" );
0 commit comments