Fixed: After canceling a sharing, application goes back to the search menu #2296 (#5156)

* fixed:After canceling a sharing, application goes back to the search menu #2296

* fixed:After canceling a sharing, application goes back to the search menu #2296

* fixed:After canceling a sharing, application goes back to the search menu #2296

* fixed SeachActivityUnityTest failure when calling testOnBackPressed and cleaned up unnecessary code
This commit is contained in:
Arman Navodia 2023-02-27 12:12:20 +05:30 committed by GitHub
parent 7d895c4379
commit 94d462cafb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 deletions

View file

@ -188,6 +188,18 @@ public class MediaDetailPagerFragment extends CommonsDaggerSupportFragment imple
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, m.getDisplayTitle() + " \n" + m.getPageTitle().getCanonicalUri());
startActivity(Intent.createChooser(shareIntent, "Share image via..."));
//Add media detail to backstack when the share button is clicked
//So that when the share is cancelled or completed the media detail page is on top
// of back stack fixing:https://github.com/commons-app/apps-android-commons/issues/2296
FragmentManager supportFragmentManager = getActivity().getSupportFragmentManager();
if (supportFragmentManager.getBackStackEntryCount() < 2) {
supportFragmentManager
.beginTransaction()
.addToBackStack(MediaDetailPagerFragment.class.getName())
.commit();
supportFragmentManager.executePendingTransactions();
}
return true;
case R.id.menu_browser_current_image:
// View in browser