|
8 | 8 | import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;
|
9 | 9 |
|
10 | 10 | import android.Manifest;
|
| 11 | +import android.annotation.SuppressLint; |
11 | 12 | import android.content.BroadcastReceiver;
|
12 | 13 | import android.content.Context;
|
13 | 14 | import android.content.Intent;
|
|
28 | 29 | import android.view.MenuInflater;
|
29 | 30 | import android.view.MenuItem;
|
30 | 31 | import android.view.MenuItem.OnMenuItemClickListener;
|
| 32 | +import android.view.MotionEvent; |
31 | 33 | import android.view.View;
|
32 | 34 | import android.view.ViewGroup;
|
33 | 35 | import android.view.animation.Animation;
|
@@ -445,14 +447,41 @@ private void initViews() {
|
445 | 447 | }
|
446 | 448 |
|
447 | 449 | /**
|
448 |
| - * Creates bottom sheet behaviours from bottom sheets, sets initial states and visibility |
| 450 | + * a) Creates bottom sheet behaviours from bottom sheets, sets initial states and visibility |
| 451 | + * b) Gets the touch event on the map to perform following actions: |
| 452 | + * if fab is open then close fab. |
| 453 | + * if bottom sheet details are expanded then collapse bottom sheet details. |
| 454 | + * if bottom sheet details are collapsed then hide the bottom sheet details. |
| 455 | + * if listBottomSheet is open then hide the list bottom sheet. |
449 | 456 | */
|
| 457 | + @SuppressLint("ClickableViewAccessibility") |
450 | 458 | private void initBottomSheets() {
|
451 | 459 | bottomSheetListBehavior = BottomSheetBehavior.from(rlBottomSheet);
|
452 | 460 | bottomSheetDetailsBehavior = BottomSheetBehavior.from(bottomSheetDetails);
|
453 | 461 | bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
454 | 462 | bottomSheetDetails.setVisibility(View.VISIBLE);
|
455 | 463 | bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
|
| 464 | + |
| 465 | + mapView.setOnTouchListener((v, event) -> { |
| 466 | + |
| 467 | + // Motion event is triggered two times on a touch event, one as ACTION_UP |
| 468 | + // and other as ACTION_DOWN, we only want one trigger per touch event. |
| 469 | + |
| 470 | + if(event.getAction() == MotionEvent.ACTION_DOWN) { |
| 471 | + if (isFABsExpanded) { |
| 472 | + collapseFABs(true); |
| 473 | + } else if (bottomSheetDetailsBehavior.getState() |
| 474 | + == BottomSheetBehavior.STATE_EXPANDED) { |
| 475 | + bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); |
| 476 | + } else if (bottomSheetDetailsBehavior.getState() |
| 477 | + == BottomSheetBehavior.STATE_COLLAPSED) { |
| 478 | + bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); |
| 479 | + } else if (isListBottomSheetExpanded()) { |
| 480 | + bottomSheetListBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); |
| 481 | + } |
| 482 | + } |
| 483 | + return false; |
| 484 | + }); |
456 | 485 | }
|
457 | 486 |
|
458 | 487 | public void initNearbyFilter() {
|
|
0 commit comments