8181import fr .free .nrw .commons .utils .ViewUtil ;
8282import timber .log .Timber ;
8383
84-
85-
84+ import android .support .design .widget .FloatingActionButton ;
8685import static fr .free .nrw .commons .upload .ExistingFileAsync .Result .DUPLICATE_PROCEED ;
8786import static fr .free .nrw .commons .upload .ExistingFileAsync .Result .NO_DUPLICATE ;
8887import static java .lang .Long .min ;
@@ -122,6 +121,7 @@ public class ShareActivity
122121 private Uri mediaUri ;
123122 private Contribution contribution ;
124123 private SimpleDraweeView backgroundImageView ;
124+ private FloatingActionButton maps_fragment ;
125125
126126 private boolean cacheFound ;
127127
@@ -145,6 +145,8 @@ public class ShareActivity
145145 private long ShortAnimationDuration ;
146146 private FloatingActionButton zoomInButton ;
147147 private FloatingActionButton zoomOutButton ;
148+ private FloatingActionButton mainFab ;
149+ private boolean isFABOpen = false ;
148150
149151
150152 /**
@@ -284,6 +286,24 @@ R.drawable.ic_error_outline_black_24dp, getTheme()))
284286 if (mediaUri != null ) {
285287 backgroundImageView .setImageURI (mediaUri );
286288 }
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+
287307 zoomInButton = (FloatingActionButton ) findViewById (R .id .media_upload_zoom_in );
288308 try {
289309 zoomInButton .setOnClickListener (new View .OnClickListener () {
@@ -358,8 +378,75 @@ public void onClick(View v) {
358378 .commitAllowingStateLoss ();
359379 }
360380 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+ });
361447 }
362448
449+
363450 @ Override
364451 public void onRequestPermissionsResult (int requestCode ,
365452 @ NonNull String [] permissions , @ NonNull int [] grantResults ) {
@@ -461,6 +548,9 @@ private void performUnwantedPictureDetectionProcess() {
461548 detectUnwantedPicturesAsync .execute ();
462549 }
463550
551+ /*
552+ * to display permission snackbar in share activity
553+ */
464554 private Snackbar requestPermissionUsingSnackBar (String rationale ,
465555 final String [] perms ,
466556 final int code ) {
@@ -693,7 +783,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
693783 return super .onOptionsItemSelected (item );
694784 }
695785
696- // Get SHA1 of file from input stream
786+ /*
787+ * Get SHA1 of file from input stream
788+ */
697789 private String getSHA1 (InputStream is ) {
698790
699791 MessageDigest digest ;
@@ -730,13 +822,18 @@ private String getSHA1(InputStream is) {
730822 }
731823 }
732824
825+ /*
826+ * function to provide pinch zoom
827+ */
733828 private void zoomImageFromThumb (final View thumbView , Uri imageuri ) {
734829 // If there's an animation in progress, cancel it
735830 // immediately and proceed with this one.
736831 if (CurrentAnimator != null ) {
737832 CurrentAnimator .cancel ();
738833 }
739834 ViewUtil .hideKeyboard (ShareActivity .this .findViewById (R .id .titleEdit | R .id .descEdit ));
835+ closeFABMenu ();
836+ mainFab .setVisibility (View .GONE );
740837 InputStream input = null ;
741838 Bitmap scaled = null ;
742839 try {
@@ -866,7 +963,7 @@ public void onClick(View view) {
866963 CurrentAnimator .cancel ();
867964 }
868965 zoomOutButton .setVisibility (View .GONE );
869- zoomInButton .setVisibility (View .VISIBLE );
966+ mainFab .setVisibility (View .VISIBLE );
870967
871968 // Animate the four positioning/sizing properties in parallel,
872969 // back to their original values.
0 commit comments