81
81
import fr .free .nrw .commons .utils .ViewUtil ;
82
82
import timber .log .Timber ;
83
83
84
-
85
-
84
+ import android .support .design .widget .FloatingActionButton ;
86
85
import static fr .free .nrw .commons .upload .ExistingFileAsync .Result .DUPLICATE_PROCEED ;
87
86
import static fr .free .nrw .commons .upload .ExistingFileAsync .Result .NO_DUPLICATE ;
88
87
import static java .lang .Long .min ;
@@ -122,6 +121,7 @@ public class ShareActivity
122
121
private Uri mediaUri ;
123
122
private Contribution contribution ;
124
123
private SimpleDraweeView backgroundImageView ;
124
+ private FloatingActionButton maps_fragment ;
125
125
126
126
private boolean cacheFound ;
127
127
@@ -145,6 +145,8 @@ public class ShareActivity
145
145
private long ShortAnimationDuration ;
146
146
private FloatingActionButton zoomInButton ;
147
147
private FloatingActionButton zoomOutButton ;
148
+ private FloatingActionButton mainFab ;
149
+ private boolean isFABOpen = false ;
148
150
149
151
150
152
/**
@@ -284,6 +286,24 @@ R.drawable.ic_error_outline_black_24dp, getTheme()))
284
286
if (mediaUri != null ) {
285
287
backgroundImageView .setImageURI (mediaUri );
286
288
}
289
+
290
+ mainFab = (FloatingActionButton ) findViewById (R .id .main_fab );
291
+ /*
292
+ * called when upper arrow floating button
293
+ */
294
+ mainFab .setOnClickListener (new View .OnClickListener () {
295
+ @ Override
296
+ public void onClick (View v ) {
297
+ if (!isFABOpen ){
298
+ showFABMenu ();
299
+ }else {
300
+ closeFABMenu ();
301
+ }
302
+ }
303
+ });
304
+
305
+
306
+
287
307
zoomInButton = (FloatingActionButton ) findViewById (R .id .media_upload_zoom_in );
288
308
try {
289
309
zoomInButton .setOnClickListener (new View .OnClickListener () {
@@ -358,8 +378,75 @@ public void onClick(View v) {
358
378
.commitAllowingStateLoss ();
359
379
}
360
380
uploadController .prepareService ();
381
+ maps_fragment = (FloatingActionButton ) findViewById (R .id .media_map );
382
+ maps_fragment .setVisibility (View .VISIBLE );
383
+ if ( imageObj == null || imageObj .imageCoordsExists != true ){
384
+ maps_fragment .setVisibility (View .INVISIBLE );
385
+ }
386
+
387
+
388
+ maps_fragment .setOnClickListener (new View .OnClickListener () {
389
+ @ Override
390
+ public void onClick (View v ) {
391
+ if ( imageObj != null && imageObj .imageCoordsExists == true ) {
392
+ Uri gmmIntentUri = Uri .parse ("google.streetview:cbll=" + imageObj .getDecLatitude () + "," + imageObj .getDecLongitude ());
393
+ Intent mapIntent = new Intent (Intent .ACTION_VIEW , gmmIntentUri );
394
+ mapIntent .setPackage ("com.google.android.apps.maps" );
395
+ startActivity (mapIntent );
396
+ }
397
+ }
398
+ });
399
+ }
400
+ /*
401
+ * Function to display the zoom and map FAB
402
+ */
403
+ private void showFABMenu (){
404
+ isFABOpen =true ;
405
+
406
+ if ( imageObj != null && imageObj .imageCoordsExists == true )
407
+ maps_fragment .setVisibility (View .VISIBLE );
408
+ zoomInButton .setVisibility (View .VISIBLE );
409
+
410
+ mainFab .animate ().rotationBy (180 );
411
+ maps_fragment .animate ().translationY (-getResources ().getDimension (R .dimen .second_fab ));
412
+ zoomInButton .animate ().translationY (-getResources ().getDimension (R .dimen .first_fab ));
413
+ }
414
+
415
+ /*
416
+ * function to close the zoom and map FAB
417
+ */
418
+ private void closeFABMenu (){
419
+ isFABOpen =false ;
420
+ mainFab .animate ().rotationBy (-180 );
421
+ maps_fragment .animate ().translationY (0 );
422
+ zoomInButton .animate ().translationY (0 ).setListener (new Animator .AnimatorListener () {
423
+ @ Override
424
+ public void onAnimationStart (Animator animator ) {
425
+
426
+ }
427
+
428
+ @ Override
429
+ public void onAnimationEnd (Animator animator ) {
430
+ if (!isFABOpen ){
431
+ maps_fragment .setVisibility (View .GONE );
432
+ zoomInButton .setVisibility (View .GONE );
433
+ }
434
+
435
+ }
436
+
437
+ @ Override
438
+ public void onAnimationCancel (Animator animator ) {
439
+
440
+ }
441
+
442
+ @ Override
443
+ public void onAnimationRepeat (Animator animator ) {
444
+
445
+ }
446
+ });
361
447
}
362
448
449
+
363
450
@ Override
364
451
public void onRequestPermissionsResult (int requestCode ,
365
452
@ NonNull String [] permissions , @ NonNull int [] grantResults ) {
@@ -461,6 +548,9 @@ private void performUnwantedPictureDetectionProcess() {
461
548
detectUnwantedPicturesAsync .execute ();
462
549
}
463
550
551
+ /*
552
+ * to display permission snackbar in share activity
553
+ */
464
554
private Snackbar requestPermissionUsingSnackBar (String rationale ,
465
555
final String [] perms ,
466
556
final int code ) {
@@ -693,7 +783,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
693
783
return super .onOptionsItemSelected (item );
694
784
}
695
785
696
- // Get SHA1 of file from input stream
786
+ /*
787
+ * Get SHA1 of file from input stream
788
+ */
697
789
private String getSHA1 (InputStream is ) {
698
790
699
791
MessageDigest digest ;
@@ -730,13 +822,18 @@ private String getSHA1(InputStream is) {
730
822
}
731
823
}
732
824
825
+ /*
826
+ * function to provide pinch zoom
827
+ */
733
828
private void zoomImageFromThumb (final View thumbView , Uri imageuri ) {
734
829
// If there's an animation in progress, cancel it
735
830
// immediately and proceed with this one.
736
831
if (CurrentAnimator != null ) {
737
832
CurrentAnimator .cancel ();
738
833
}
739
834
ViewUtil .hideKeyboard (ShareActivity .this .findViewById (R .id .titleEdit | R .id .descEdit ));
835
+ closeFABMenu ();
836
+ mainFab .setVisibility (View .GONE );
740
837
InputStream input = null ;
741
838
Bitmap scaled = null ;
742
839
try {
@@ -866,7 +963,7 @@ public void onClick(View view) {
866
963
CurrentAnimator .cancel ();
867
964
}
868
965
zoomOutButton .setVisibility (View .GONE );
869
- zoomInButton .setVisibility (View .VISIBLE );
966
+ mainFab .setVisibility (View .VISIBLE );
870
967
871
968
// Animate the four positioning/sizing properties in parallel,
872
969
// back to their original values.
0 commit comments