Search in sources :

Example 51 with DialogFragment

use of androidx.fragment.app.DialogFragment in project OneSignal-Android-SDK by OneSignal.

the class OSSystemConditionController method isDialogFragmentShowing.

boolean isDialogFragmentShowing(Context context) throws NoClassDefFoundError {
    // Detect if user has a dialog fragment showing
    if (context instanceof AppCompatActivity) {
        final FragmentManager manager = ((AppCompatActivity) context).getSupportFragmentManager();
        manager.registerFragmentLifecycleCallbacks(new FragmentManager.FragmentLifecycleCallbacks() {

            @Override
            public void onFragmentDetached(@NonNull FragmentManager fm, @NonNull Fragment fragmentDetached) {
                super.onFragmentDetached(fm, fragmentDetached);
                if (fragmentDetached instanceof DialogFragment) {
                    manager.unregisterFragmentLifecycleCallbacks(this);
                    systemConditionObserver.systemConditionChanged();
                }
            }
        }, true);
        List<Fragment> fragments = manager.getFragments();
        int size = fragments.size();
        if (size > 0) {
            // We only care of the last fragment available
            Fragment fragment = fragments.get(size - 1);
            return fragment.isVisible() && fragment instanceof DialogFragment;
        }
    }
    // We cannot detect AlertDialogs because they are added to the decor view as linear layout without an identification
    return false;
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) DialogFragment(androidx.fragment.app.DialogFragment) Fragment(androidx.fragment.app.Fragment) DialogFragment(androidx.fragment.app.DialogFragment)

Example 52 with DialogFragment

use of androidx.fragment.app.DialogFragment in project k-9 by k9mail.

the class MessageViewFragment method showDialog.

private void showDialog(int dialogId) {
    DialogFragment fragment;
    if (dialogId == R.id.dialog_confirm_delete) {
        String title = getString(R.string.dialog_confirm_delete_title);
        String message = getString(R.string.dialog_confirm_delete_message);
        String confirmText = getString(R.string.dialog_confirm_delete_confirm_button);
        String cancelText = getString(R.string.dialog_confirm_delete_cancel_button);
        fragment = ConfirmationDialogFragment.newInstance(dialogId, title, message, confirmText, cancelText);
    } else if (dialogId == R.id.dialog_confirm_spam) {
        String title = getString(R.string.dialog_confirm_spam_title);
        String message = getResources().getQuantityString(R.plurals.dialog_confirm_spam_message, 1);
        String confirmText = getString(R.string.dialog_confirm_spam_confirm_button);
        String cancelText = getString(R.string.dialog_confirm_spam_cancel_button);
        fragment = ConfirmationDialogFragment.newInstance(dialogId, title, message, confirmText, cancelText);
    } else if (dialogId == R.id.dialog_attachment_progress) {
        String message = getString(R.string.dialog_attachment_progress_title);
        long size = currentAttachmentViewInfo.size;
        fragment = AttachmentDownloadDialogFragment.newInstance(size, message);
    } else {
        throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
    }
    fragment.setTargetFragment(this, dialogId);
    fragment.show(getParentFragmentManager(), getDialogTag(dialogId));
}
Also used : AttachmentDownloadDialogFragment(com.fsck.k9.fragment.AttachmentDownloadDialogFragment) ConfirmationDialogFragment(com.fsck.k9.fragment.ConfirmationDialogFragment) DialogFragment(androidx.fragment.app.DialogFragment)

Example 53 with DialogFragment

use of androidx.fragment.app.DialogFragment in project k-9 by k9mail.

the class MessageViewFragment method removeDialog.

private void removeDialog(int dialogId) {
    if (!isAdded()) {
        return;
    }
    FragmentManager fm = getParentFragmentManager();
    // Make sure the "show dialog" transaction has been processed when we call
    // findFragmentByTag() below. Otherwise the fragment won't be found and the dialog will
    // never be dismissed.
    fm.executePendingTransactions();
    DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(getDialogTag(dialogId));
    if (fragment != null) {
        fragment.dismissAllowingStateLoss();
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) AttachmentDownloadDialogFragment(com.fsck.k9.fragment.AttachmentDownloadDialogFragment) ConfirmationDialogFragment(com.fsck.k9.fragment.ConfirmationDialogFragment) DialogFragment(androidx.fragment.app.DialogFragment)

Example 54 with DialogFragment

use of androidx.fragment.app.DialogFragment in project Signal-Android by signalapp.

the class GroupLinkShareQrDialogFragment method show.

public static void show(@NonNull FragmentManager manager, @NonNull GroupId.V2 groupId) {
    DialogFragment fragment = new GroupLinkShareQrDialogFragment();
    Bundle args = new Bundle();
    args.putString(ARG_GROUP_ID, groupId.toString());
    fragment.setArguments(args);
    fragment.show(manager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG);
}
Also used : Bundle(android.os.Bundle) DialogFragment(androidx.fragment.app.DialogFragment)

Example 55 with DialogFragment

use of androidx.fragment.app.DialogFragment in project Signal-Android by signalapp.

the class ReactWithAnyEmojiBottomSheetDialogFragment method createForEditReactions.

public static DialogFragment createForEditReactions() {
    DialogFragment fragment = new ReactWithAnyEmojiBottomSheetDialogFragment();
    Bundle args = new Bundle();
    args.putLong(ARG_MESSAGE_ID, -1);
    args.putBoolean(ARG_IS_MMS, false);
    args.putInt(ARG_START_PAGE, -1);
    args.putBoolean(ARG_SHADOWS, false);
    args.putString(ARG_RECENT_KEY, REACTION_STORAGE_KEY);
    fragment.setArguments(args);
    return fragment;
}
Also used : Bundle(android.os.Bundle) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) DialogFragment(androidx.fragment.app.DialogFragment)

Aggregations

DialogFragment (androidx.fragment.app.DialogFragment)62 Bundle (android.os.Bundle)22 InstrumentedDialogFragment (com.android.settings.core.instrumentation.InstrumentedDialogFragment)8 BottomSheetDialogFragment (com.google.android.material.bottomsheet.BottomSheetDialogFragment)8 Intent (android.content.Intent)7 Fragment (androidx.fragment.app.Fragment)5 FragmentTransaction (androidx.fragment.app.FragmentTransaction)4 Test (org.junit.Test)4 FullScreenDialogFragment (org.thoughtcrime.securesms.components.FullScreenDialogFragment)4 NonNull (androidx.annotation.NonNull)3 FragmentManager (androidx.fragment.app.FragmentManager)3 ConfirmationDialogFragment (com.fsck.k9.fragment.ConfirmationDialogFragment)3 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)3 OCFile (com.owncloud.android.datamodel.OCFile)3 OCUpload (com.owncloud.android.db.OCUpload)3 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)3 FragmentActivity (androidx.fragment.app.FragmentActivity)2 CustomDialogPreferenceCompat (com.android.settingslib.CustomDialogPreferenceCompat)2 CustomEditTextPreferenceCompat (com.android.settingslib.CustomEditTextPreferenceCompat)2 AttachmentDownloadDialogFragment (com.fsck.k9.fragment.AttachmentDownloadDialogFragment)2