Search in sources :

Example 1 with OnBackPressedListener

use of com.waz.zclient.OnBackPressedListener in project wire-android by wireapp.

the class MainPhoneFragment method onBackPressed.

////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Notifications
//
////////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public boolean onBackPressed() {
    if (confirmationMenu.getVisibility() == View.VISIBLE) {
        confirmationMenu.animateToShow(false);
        return true;
    }
    // Clear any overlays
    dismissOnBoardingHint(OnBoardingHintType.NONE);
    if (getChildFragmentManager().getBackStackEntryCount() > 0) {
        Fragment topFragment = getChildFragmentManager().findFragmentByTag(getChildFragmentManager().getBackStackEntryAt(getChildFragmentManager().getBackStackEntryCount() - 1).getName());
        if (topFragment instanceof SingleImageFragment) {
            return ((SingleImageFragment) topFragment).onBackPressed();
        } else if (topFragment instanceof VideoPlayerFragment) {
            return ((VideoPlayerFragment) topFragment).onBackPressed();
        } else if (topFragment instanceof GiphySharingPreviewFragment) {
            if (!((GiphySharingPreviewFragment) topFragment).onBackPressed()) {
                getChildFragmentManager().popBackStackImmediate(GiphySharingPreviewFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
            }
            return true;
        } else if (topFragment instanceof CollectionFragment) {
            return ((CollectionFragment) topFragment).onBackPressed();
        } else if (topFragment instanceof ConfirmationFragment) {
            return ((ConfirmationFragment) topFragment).onBackPressed();
        }
    }
    // Back press is first delivered to the notification fragment, and if it's not consumed there,
    // it's then delivered to the main content.
    Fragment fragment = getChildFragmentManager().findFragmentById(R.id.fl_fragment_main_content);
    if (fragment instanceof OnBackPressedListener && ((OnBackPressedListener) fragment).onBackPressed()) {
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__overlay_container);
    if (fragment instanceof OnBackPressedListener && ((OnBackPressedListener) fragment).onBackPressed()) {
        return true;
    }
    return getChildFragmentManager().popBackStackImmediate();
}
Also used : ConfirmationFragment(com.waz.zclient.pages.main.conversationlist.ConfirmationFragment) OnBackPressedListener(com.waz.zclient.OnBackPressedListener) SingleImageFragment(com.waz.zclient.pages.main.conversation.SingleImageFragment) VideoPlayerFragment(com.waz.zclient.pages.main.conversation.VideoPlayerFragment) CollectionFragment(com.waz.zclient.conversation.CollectionFragment) ConfirmationFragment(com.waz.zclient.pages.main.conversationlist.ConfirmationFragment) SingleImageUserFragment(com.waz.zclient.pages.main.conversation.SingleImageUserFragment) ShareToMultipleFragment(com.waz.zclient.conversation.ShareToMultipleFragment) CollectionFragment(com.waz.zclient.conversation.CollectionFragment) SingleImageFragment(com.waz.zclient.pages.main.conversation.SingleImageFragment) SingleImageMessageFragment(com.waz.zclient.pages.main.conversation.SingleImageMessageFragment) ConversationPagerFragment(com.waz.zclient.pages.main.conversationpager.ConversationPagerFragment) OnBoardingHintFragment(com.waz.zclient.pages.main.onboarding.OnBoardingHintFragment) Fragment(android.support.v4.app.Fragment) VideoPlayerFragment(com.waz.zclient.pages.main.conversation.VideoPlayerFragment) BaseFragment(com.waz.zclient.pages.BaseFragment) GiphySharingPreviewFragment(com.waz.zclient.pages.main.giphy.GiphySharingPreviewFragment) GiphySharingPreviewFragment(com.waz.zclient.pages.main.giphy.GiphySharingPreviewFragment)

Example 2 with OnBackPressedListener

use of com.waz.zclient.OnBackPressedListener in project wire-android by wireapp.

the class RootFragment method onBackPressed.

@Override
public boolean onBackPressed() {
    Fragment fragment = getChildFragmentManager().findFragmentByTag(ParticipantsDialogFragment.TAG);
    if (fragment instanceof OnBackPressedListener && ((OnBackPressedListener) fragment).onBackPressed()) {
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__right_view);
    if (fragment instanceof OnBackPressedListener && ((OnBackPressedListener) fragment).onBackPressed()) {
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__camera);
    if (fragment instanceof CameraFragment) {
        //TODO: https://wearezeta.atlassian.net/browse/AN-2311 Refactor camera into one view
        getControllerFactory().getCameraController().closeCamera(((CameraFragment) fragment).getCameraContext());
        return true;
    } else if (fragment instanceof OnBackPressedListener) {
        ((OnBackPressedListener) fragment).onBackPressed();
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__giphy);
    if (fragment instanceof GiphySharingPreviewFragment) {
        if (!((GiphySharingPreviewFragment) fragment).onBackPressed()) {
            getControllerFactory().getGiphyController().cancel();
        }
        return true;
    }
    fragment = getChildFragmentManager().findFragmentById(R.id.fl__root__sketch);
    if (fragment instanceof OnBackPressedListener) {
        ((OnBackPressedListener) fragment).onBackPressed();
        return true;
    }
    if (getControllerFactory().getPickUserController().isShowingPickUser(IPickUserController.Destination.CONVERSATION_LIST)) {
        getControllerFactory().getPickUserController().hidePickUser(IPickUserController.Destination.CONVERSATION_LIST, true);
        return true;
    }
    if (slidingPaneLayout != null && !slidingPaneLayout.isOpen()) {
        slidingPaneLayout.openPane();
        return true;
    }
    return false;
}
Also used : OnBackPressedListener(com.waz.zclient.OnBackPressedListener) CameraFragment(com.waz.zclient.pages.main.profile.camera.CameraFragment) DrawingFragment(com.waz.zclient.pages.main.drawing.DrawingFragment) LocationFragment(com.waz.zclient.pages.main.conversation.LocationFragment) CollectionFragment(com.waz.zclient.conversation.CollectionFragment) Fragment(android.support.v4.app.Fragment) GiphySharingPreviewFragment(com.waz.zclient.pages.main.giphy.GiphySharingPreviewFragment) ConversationFragment(com.waz.zclient.pages.main.conversation.ConversationFragment) ParticipantsDialogFragment(com.waz.zclient.pages.main.participants.dialog.ParticipantsDialogFragment) PendingConnectRequestManagerFragment(com.waz.zclient.pages.main.connect.PendingConnectRequestManagerFragment) CameraFragment(com.waz.zclient.pages.main.profile.camera.CameraFragment) ConversationListManagerFragment(com.waz.zclient.pages.main.conversationlist.ConversationListManagerFragment) TabbedParticipantBodyFragment(com.waz.zclient.pages.main.participants.TabbedParticipantBodyFragment) ConnectRequestInboxManagerFragment(com.waz.zclient.pages.main.connect.ConnectRequestInboxManagerFragment) BaseFragment(com.waz.zclient.pages.BaseFragment) GiphySharingPreviewFragment(com.waz.zclient.pages.main.giphy.GiphySharingPreviewFragment)

Example 3 with OnBackPressedListener

use of com.waz.zclient.OnBackPressedListener in project wire-android by wireapp.

the class ParticipantsDialogFragment method onBackPressed.

@Override
public boolean onBackPressed() {
    Fragment fragment = getChildFragmentManager().findFragmentByTag(ParticipantFragment.TAG);
    if (fragment instanceof OnBackPressedListener && ((OnBackPressedListener) fragment).onBackPressed()) {
        return true;
    }
    if (animateBetweenMainAndDetail(true)) {
        return true;
    }
    hide();
    return true;
}
Also used : OnBackPressedListener(com.waz.zclient.OnBackPressedListener) BlockedUserProfileFragment(com.waz.zclient.pages.main.connect.BlockedUserProfileFragment) Fragment(android.support.v4.app.Fragment) ParticipantFragment(com.waz.zclient.pages.main.participants.ParticipantFragment) SingleParticipantFragment(com.waz.zclient.pages.main.participants.SingleParticipantFragment) PendingConnectRequestManagerFragment(com.waz.zclient.pages.main.connect.PendingConnectRequestManagerFragment) SendConnectRequestFragment(com.waz.zclient.pages.main.connect.SendConnectRequestFragment) PickUserFragment(com.waz.zclient.pages.main.pickuser.PickUserFragment) TabbedParticipantBodyFragment(com.waz.zclient.pages.main.participants.TabbedParticipantBodyFragment) BaseFragment(com.waz.zclient.pages.BaseFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)3 OnBackPressedListener (com.waz.zclient.OnBackPressedListener)3 BaseFragment (com.waz.zclient.pages.BaseFragment)3 CollectionFragment (com.waz.zclient.conversation.CollectionFragment)2 PendingConnectRequestManagerFragment (com.waz.zclient.pages.main.connect.PendingConnectRequestManagerFragment)2 GiphySharingPreviewFragment (com.waz.zclient.pages.main.giphy.GiphySharingPreviewFragment)2 TabbedParticipantBodyFragment (com.waz.zclient.pages.main.participants.TabbedParticipantBodyFragment)2 ShareToMultipleFragment (com.waz.zclient.conversation.ShareToMultipleFragment)1 BlockedUserProfileFragment (com.waz.zclient.pages.main.connect.BlockedUserProfileFragment)1 ConnectRequestInboxManagerFragment (com.waz.zclient.pages.main.connect.ConnectRequestInboxManagerFragment)1 SendConnectRequestFragment (com.waz.zclient.pages.main.connect.SendConnectRequestFragment)1 ConversationFragment (com.waz.zclient.pages.main.conversation.ConversationFragment)1 LocationFragment (com.waz.zclient.pages.main.conversation.LocationFragment)1 SingleImageFragment (com.waz.zclient.pages.main.conversation.SingleImageFragment)1 SingleImageMessageFragment (com.waz.zclient.pages.main.conversation.SingleImageMessageFragment)1 SingleImageUserFragment (com.waz.zclient.pages.main.conversation.SingleImageUserFragment)1 VideoPlayerFragment (com.waz.zclient.pages.main.conversation.VideoPlayerFragment)1 ConfirmationFragment (com.waz.zclient.pages.main.conversationlist.ConfirmationFragment)1 ConversationListManagerFragment (com.waz.zclient.pages.main.conversationlist.ConversationListManagerFragment)1 ConversationPagerFragment (com.waz.zclient.pages.main.conversationpager.ConversationPagerFragment)1