mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* Fixes #3923 * Handled possible missing backpress cases in MainActivity-nearby * Fixes #3923 * Handled possible missing backpress cases in MainActivity-nearby
This commit is contained in:
parent
6e8e4f7a41
commit
b8ba89d077
5 changed files with 15 additions and 14 deletions
|
|
@ -242,7 +242,7 @@ public class MainActivity extends NavigationBaseActivity implements FragmentMana
|
|||
// Meas that contribution fragment is visible (not nearby fragment)
|
||||
ContributionsFragment contributionsFragment = (ContributionsFragment) getSupportFragmentManager().findFragmentByTag(contributionsFragmentTag);
|
||||
|
||||
if (contributionsFragment.getChildFragmentManager().findFragmentByTag(ContributionsFragment.MEDIA_DETAIL_PAGER_FRAGMENT_TAG) != null) {
|
||||
if (contributionsFragment.getChildFragmentManager().getBackStackEntryCount()>0 ) {
|
||||
// Means that media details fragment is visible to uer instead of contributions list fragment (As chils fragment)
|
||||
// Then we want to go back to contributions list fragment on backbutton pressed from media detail fragment
|
||||
contributionsFragment.getChildFragmentManager().popBackStack();
|
||||
|
|
@ -257,12 +257,13 @@ public class MainActivity extends NavigationBaseActivity implements FragmentMana
|
|||
contributionsFragment.nearbyNotificationCardView.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
finish();
|
||||
super.onBackPressed();
|
||||
}
|
||||
} else if (getSupportFragmentManager().findFragmentByTag(nearbyFragmentTag) != null && !isContributionsFragmentVisible) {
|
||||
} else if (getSupportFragmentManager().findFragmentByTag(nearbyFragmentTag) != null
|
||||
&& !isContributionsFragmentVisible) {
|
||||
// Means that nearby fragment is visible (not contributions fragment)
|
||||
if (null != nearbyParentFragment) {
|
||||
nearbyParentFragment.backButtonClicked();
|
||||
if (null == nearbyParentFragment || !nearbyParentFragment.backButtonClicked()) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public interface NearbyParentFragmentContract {
|
|||
void detachView();
|
||||
|
||||
void setActionListeners(JsonKvStore applicationKvStore);
|
||||
void backButtonClicked();
|
||||
boolean backButtonClicked();
|
||||
void onCameraMove(com.mapbox.mapboxsdk.geometry.LatLng latLng);
|
||||
void filterByMarkerType(List<Label> selectedLabels, int state, boolean filterForPlaceState, boolean filterForAllNoneType);
|
||||
|
||||
|
|
|
|||
|
|
@ -980,8 +980,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
|
||||
public void backButtonClicked() {
|
||||
presenter.backButtonClicked();
|
||||
public boolean backButtonClicked() {
|
||||
return presenter.backButtonClicked();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -111,16 +111,16 @@ public class NearbyParentFragmentPresenter
|
|||
}
|
||||
|
||||
@Override
|
||||
public void backButtonClicked() {
|
||||
public boolean backButtonClicked() {
|
||||
if(nearbyParentFragmentView.isListBottomSheetExpanded()) {
|
||||
// Back should first hide the bottom sheet if it is expanded
|
||||
nearbyParentFragmentView.listOptionMenuItemClicked();
|
||||
return true;
|
||||
} else if (nearbyParentFragmentView.isDetailsBottomSheetVisible()) {
|
||||
nearbyParentFragmentView.setBottomSheetDetailsSmaller();
|
||||
} else {
|
||||
// Otherwise go back to contributions fragment
|
||||
nearbyParentFragmentView.setTabItemContributions();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void markerUnselected() {
|
||||
|
|
|
|||
|
|
@ -374,8 +374,8 @@ class NearbyParentFragmentPresenterTest {
|
|||
fun testBackButtonClickedWhenNoSheetVisible() {
|
||||
whenever(nearbyParentFragmentView.isListBottomSheetExpanded()).thenReturn(false)
|
||||
whenever(nearbyParentFragmentView.isDetailsBottomSheetVisible()).thenReturn(false)
|
||||
nearbyPresenter.backButtonClicked()
|
||||
verify(nearbyParentFragmentView).setTabItemContributions()
|
||||
val hasNearbyHandledBackPress = nearbyPresenter.backButtonClicked()
|
||||
assertFalse(hasNearbyHandledBackPress)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue