Fixes #3923 (Back" does nothing in Nearby in particular circumstance) (#3961)

* 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:
Ashish 2020-10-21 01:11:17 +05:30 committed by GitHub
parent 6e8e4f7a41
commit b8ba89d077
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 14 deletions

View file

@ -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();

View file

@ -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);

View file

@ -980,8 +980,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
}
}
public void backButtonClicked() {
presenter.backButtonClicked();
public boolean backButtonClicked() {
return presenter.backButtonClicked();
}
/**

View file

@ -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() {

View file

@ -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