androidx.fragment.app.DialogFragment Java Examples

The following examples show how to use androidx.fragment.app.DialogFragment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: cordova-plugin-foxitpdf   Author: foxitsoftware   File: ScannerListActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showScannerList() {
    FragmentManager fm = getSupportFragmentManager();
    DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(SANNER_LIST_TAG);
    FragmentTransaction transaction = fm.beginTransaction();
    if (fragment == null) {
        fragment = PDFScanManager.createScannerFragment(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                PDFScanManager.unregisterManagerListener(scanManagerListener);
                ScannerListActivity.this.finish();
            }
        });
    } else {
        transaction.remove(fragment);
    }
    transaction.add(fragment, SANNER_LIST_TAG);
    transaction.commitAllowingStateLoss();
    PDFScanManager.registerManagerListener(scanManagerListener);
}
 
Example #2
Source Project: mollyim-android   Author: mollyim   File: CorrectedPreferenceFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
  DialogFragment dialogFragment = null;

  if (preference instanceof ColorPickerPreference) {
    dialogFragment = ColorPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey());
  } else if (preference instanceof CustomDefaultPreference) {
    dialogFragment = CustomDefaultPreference.CustomDefaultPreferenceDialogFragmentCompat.newInstance(preference.getKey());
  }

  if (dialogFragment != null) {
    dialogFragment.setTargetFragment(this, 0);
    dialogFragment.show(getFragmentManager(), "android.support.v7.preference.PreferenceFragment.DIALOG");
  } else {
    super.onDisplayPreferenceDialog(preference);
  }
}
 
Example #3
Source Project: leafpicrevived   Author: apcro   File: ProgressBottomSheet.java    License: GNU General Public License v3.0 6 votes vote down vote up
public ProgressBottomSheet<T> build() {
    if (sources == null)
        throw new RuntimeException("You must pass a list of observables");

    if (listener == null)
        Log.w(TAG, "You have not set a listener");

    ProgressBottomSheet<T> bottomSheet = new ProgressBottomSheet<>();

    bottomSheet.setTitle(title);
    bottomSheet.setAutoDismiss(autoDismiss);
    bottomSheet.setShowCancel(showCancel);
    bottomSheet.setSources(sources);
    bottomSheet.setListener(listener);
    bottomSheet.setStyle(DialogFragment.STYLE_NORMAL, R.style.AppTheme);
    return bottomSheet;

}
 
Example #4
Source Project: bitmask_android   Author: leapcode   File: MainActivityErrorDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return a new instance of this DialogFragment.
 */
public static DialogFragment newInstance(Provider provider, JSONObject errorJson) {
    MainActivityErrorDialog dialogFragment = new MainActivityErrorDialog();
    dialogFragment.provider = provider;
    try {
        if (errorJson.has(ERRORS)) {
            dialogFragment.reasonToFail = errorJson.getString(ERRORS);
        } else {
            //default error msg
            dialogFragment.reasonToFail = dialogFragment.getString(R.string.error_io_exception_user_message);
        }

        if (errorJson.has(ERRORID)) {
            dialogFragment.downloadError = valueOf(errorJson.getString(ERRORID));
        }
    } catch (Exception e) {
        e.printStackTrace();
        dialogFragment.reasonToFail = dialogFragment.getString(R.string.error_io_exception_user_message);
    }
    return dialogFragment;
}
 
Example #5
Source Project: prayer-times-android   Author: metinkale38   File: SettingsFragment.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("RestrictedApi")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    if (preference instanceof NumberPickerPreference) {
        boolean handled = false;
        if (getCallbackFragment() instanceof OnPreferenceDisplayDialogCallback) {
            handled = ((OnPreferenceDisplayDialogCallback) getCallbackFragment()).onPreferenceDisplayDialog(this, preference);
        }
        if (!handled && getActivity() instanceof OnPreferenceDisplayDialogCallback) {
            handled = ((OnPreferenceDisplayDialogCallback) getActivity()).onPreferenceDisplayDialog(this, preference);
        }

        if (handled) {
            return;
        }

        if (getFragmentManager().findFragmentByTag("numberpicker") != null) {
            return;
        }

        DialogFragment f = NumberPickerPreference.NumberPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), "numberpicker");
    } else
        super.onDisplayPreferenceDialog(preference);
}
 
Example #6
Source Project: InviZible   Author: Gedsh   File: ConfigEditorFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onStop() {

    super.onStop();

    String input = etConfigEditor.getText().toString();

    if (input.isEmpty()) {
        return;
    }

    if (!input.equals(savedText) && getFragmentManager() != null) {
        DialogFragment dialogFragment = DialogSaveConfigChanges.newInstance();

        Bundle bundle = new Bundle();
        bundle.putString("moduleName", moduleName);
        bundle.putString("filePath", filePath);
        bundle.putString("fileText", input);

        dialogFragment.setArguments(bundle);

        dialogFragment.show(getFragmentManager(), "DialogSaveConfigChanges");
    }
}
 
Example #7
Source Project: an2linuxclient   Author: rootkiwi   File: AppNotificationSettingsActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    String TAG = "NumberPickerPreference";
    FragmentManager fm = getFragmentManager();
    if (fm.findFragmentByTag(TAG) != null) {
        return;
    }

    if (preference instanceof NumberPickerPreference) {
        final DialogFragment f = NumberPickerPreferenceDialog.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(fm, TAG);
    } else {
        super.onDisplayPreferenceDialog(preference);
    }
}
 
Example #8
Source Project: NGA-CLIENT-VER-OPEN-SOURCE   Author: ymback   File: ArticleTabFragment.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void createGotoDialog() {

        Bundle args = new Bundle();
        args.putInt("page", mPagerAdapter.getCount());
        args.putInt("floor", mReplyCount);

        DialogFragment df = new GotoDialogFragment();
        df.setArguments(args);
        df.setTargetFragment(this, ActivityUtils.REQUEST_CODE_JUMP_PAGE);

        FragmentManager fm = getActivity().getSupportFragmentManager();

        Fragment prev = fm.findFragmentByTag(GOTO_TAG);
        if (prev != null) {
            fm.beginTransaction().remove(prev).commit();
        }
        df.show(fm, GOTO_TAG);

    }
 
Example #9
Source Project: candybar   Author: zixpo   File: IconShapeFragment.java    License: Apache License 2.0 5 votes vote down vote up
public static void showIconShapeChooser(@NonNull FragmentManager fm) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    try {
        DialogFragment dialog = IconShapeFragment.newInstance();
        dialog.show(ft, TAG);
    } catch (IllegalArgumentException | IllegalStateException ignored) {
    }
}
 
Example #10
Source Project: GDPRDialog   Author: MFlisar   File: GDPRDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mViewManager = new GDPRViewManager(getArguments(), savedInstanceState);
    mForceActivityToImplementCallback = getArguments().getBoolean(ARG_PARENT_MUST_IMPLEMENT_CALLBACK);
    GDPRCustomTexts customTexts = mViewManager.getSetup().getCustomTexts();
    if (customTexts.hasTitle() && customTexts.getTitle(getContext()).isEmpty()) {
        setStyle(DialogFragment.STYLE_NO_TITLE, mViewManager.getSetup().customDialogTheme());
    } else {
        setStyle(DialogFragment.STYLE_NORMAL, mViewManager.getSetup().customDialogTheme());
    }
}
 
Example #11
Source Project: candybar   Author: zixpo   File: IconPreviewFragment.java    License: Apache License 2.0 5 votes vote down vote up
public static void showIconPreview(@NonNull FragmentManager fm, @NonNull String name, int id) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    try {
        DialogFragment dialog = IconPreviewFragment.newInstance(name, id);
        dialog.show(ft, TAG);
    } catch (IllegalArgumentException | IllegalStateException ignored) {
    }
}
 
Example #12
Source Project: Notepad   Author: farmerbb   File: NoteEditActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void showDeleteDialog() {
    Bundle bundle = new Bundle();
    bundle.putInt("dialog_title", R.string.dialog_delete_button_title);

    DialogFragment deleteFragment = new DeleteDialogFragment();
    deleteFragment.setArguments(bundle);
    deleteFragment.show(getSupportFragmentManager(), "delete");
}
 
Example #13
Source Project: candybar   Author: zixpo   File: OtherAppsFragment.java    License: Apache License 2.0 5 votes vote down vote up
public static void showOtherAppsDialog(@NonNull FragmentManager fm) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    try {
        DialogFragment dialog = OtherAppsFragment.newInstance();
        dialog.show(ft, TAG);
    } catch (IllegalStateException | IllegalArgumentException ignored) {
    }
}
 
Example #14
Source Project: candybar   Author: zixpo   File: LicensesFragment.java    License: Apache License 2.0 5 votes vote down vote up
public static void showLicensesDialog(FragmentManager fm) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    try {
        DialogFragment dialog = LicensesFragment.newInstance();
        dialog.show(ft, TAG);
    } catch (IllegalArgumentException | IllegalStateException ignored) {
    }
}
 
Example #15
@Test
public void testGetPromptParentView()
{
    final DialogFragment dialogFragment = spy(new DialogFragment());
    final ViewGroup parent = mock(ViewGroup.class);
    final ViewGroup view = mock(ViewGroup.class);
    final SupportFragmentResourceFinder resourceFinder = new SupportFragmentResourceFinder(dialogFragment);
    when(dialogFragment.getView()).thenReturn(view);
    when(view.getParent()).thenReturn(parent);
    assertEquals(parent, resourceFinder.getPromptParentView());
    assertEquals(parent, resourceFinder.getPromptParentView());
}
 
Example #16
public static DialogFragment createForMessageRecord(@NonNull MessageRecord messageRecord) {
  DialogFragment fragment = new ReactWithAnyEmojiBottomSheetDialogFragment();
  Bundle         args     = new Bundle();

  args.putLong(ARG_MESSAGE_ID, messageRecord.getId());
  args.putBoolean(ARG_IS_MMS, messageRecord.isMms());
  fragment.setArguments(args);

  return fragment;
}
 
Example #17
public static DialogFragment create(long messageId, boolean isMms) {
  Bundle         args     = new Bundle();
  DialogFragment fragment = new ReactionsBottomSheetDialogFragment();

  args.putLong(ARGS_MESSAGE_ID, messageId);
  args.putBoolean(ARGS_IS_MMS, isMms);

  fragment.setArguments(args);

  return fragment;
}
 
Example #18
Source Project: MaterialPreference   Author: RikkaW   File: NumberPickerPreference.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected DialogFragment onCreateDialogFragment(String key) {
    final NumberPickerPreferenceDialogFragment
            fragment = new NumberPickerPreferenceDialogFragment();
    final Bundle b = new Bundle(1);
    b.putString(PreferenceDialogFragment.ARG_KEY, key);
    fragment.setArguments(b);
    return fragment;
}
 
Example #19
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  setStyle(DialogFragment.STYLE_NORMAL,
           ThemeUtil.isDarkTheme(requireContext()) ? R.style.Theme_Signal_RecipientBottomSheet
                                                   : R.style.Theme_Signal_RecipientBottomSheet_Light);

  super.onCreate(savedInstanceState);
}
 
Example #20
Source Project: Notepad   Author: farmerbb   File: NoteEditActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void showBackButtonDialog(String filename) {
    Bundle bundle = new Bundle();
    bundle.putString("filename", filename);

    DialogFragment backFragment = new BackButtonDialogFragment();
    backFragment.setArguments(bundle);
    backFragment.show(getSupportFragmentManager(), "back");
}
 
Example #21
Source Project: AndroidQuick   Author: ddnosh   File: CodeAndRunActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("BottomDialogFragment");
    if (prev != null) {
        DialogFragment df = (DialogFragment) prev;
        df.dismiss();
    }
}
 
Example #22
Source Project: bitmask_android   Author: leapcode   File: MainActivityErrorDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return a new instance of this DialogFragment.
 */
public static DialogFragment newInstance(Provider provider, String reasonToFail, EIP.EIPErrors error) {
    MainActivityErrorDialog dialogFragment = new MainActivityErrorDialog();
    dialogFragment.reasonToFail = reasonToFail;
    dialogFragment.provider = provider;
    dialogFragment.downloadError = error;
    return dialogFragment;
}
 
Example #23
Source Project: MaterialPreference   Author: RikkaW   File: ListPreference.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected DialogFragment onCreateDialogFragment(String key) {
    final ListPreferenceDialogFragment
            fragment = new ListPreferenceDialogFragment();
    final Bundle b = new Bundle(1);
    b.putString(PreferenceDialogFragment.ARG_KEY, key);
    fragment.setArguments(b);
    return fragment;
}
 
Example #24
Source Project: SmartPack-Kernel-Manager   Author: SmartPack   File: ViewUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void showDialog(FragmentManager manager, DialogFragment fragment) {
    FragmentTransaction ft = manager.beginTransaction();
    Fragment prev = manager.findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    fragment.show(ft, "dialog");
}
 
Example #25
Source Project: SmartFlasher   Author: SmartPack   File: ViewUtils.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void showDialog(FragmentManager manager, DialogFragment fragment) {
    FragmentTransaction ft = manager.beginTransaction();
    Fragment prev = manager.findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    fragment.show(ft, "dialog");
}
 
Example #26
Source Project: MaterialPreference   Author: RikkaW   File: EditTextPreference.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
protected DialogFragment onCreateDialogFragment(String key) {
    final EditTextPreferenceDialogFragment
            fragment = new EditTextPreferenceDialogFragment();
    final Bundle b = new Bundle(1);
    b.putString(PreferenceDialogFragment.ARG_KEY, key);
    fragment.setArguments(b);
    return fragment;
}
 
Example #27
Source Project: AndroidNavigation   Author: listenzz   File: AwesomeActivity.java    License: MIT License 5 votes vote down vote up
public Window getCurrentWindow() {
    DialogFragment dialogFragment = getDialogFragment();
    if (dialogFragment != null && dialogFragment.isAdded()) {
        return dialogFragment.getDialog().getWindow();
    } else {
        return getWindow();
    }
}
 
Example #28
Source Project: Alligator   Author: aartikov   File: ScreenResolver.java    License: MIT License 5 votes vote down vote up
@NonNull
private DialogFragmentDestination getDestination(@NonNull DialogFragment dialogFragment) {
	Class<? extends Screen> screenClass = mNavigationFactory.getScreenClass(dialogFragment);
	if (screenClass == null) {
		throw new IllegalArgumentException("Failed to get screen class from " + dialogFragment.getClass().getSimpleName());
	}

	Destination destination = mNavigationFactory.getDestination(screenClass);
	if (!(destination instanceof DialogFragmentDestination)) {
		throw new IllegalArgumentException("Failed to get destination from " + dialogFragment.getClass().getSimpleName());
	}

	return (DialogFragmentDestination) destination;
}
 
Example #29
Source Project: aptoide-client-v8   Author: Aptoide   File: BaseDialogFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
  if (this.getActivity() != null && shouldUseDefaultDialogStyle()) {
    setStyle(DialogFragment.STYLE_NO_TITLE,
        themeManager.getAttributeForTheme(getDialogStyle()).resourceId);
  }
  return super.onCreateDialog(savedInstanceState);
}
 
Example #30
@Test
public void testGetDrawable()
{

    final int resourceId = 64532;
    final DialogFragment dialogFragment = spy(new DialogFragment());
    final SupportFragmentResourceFinder resourceFinder = new SupportFragmentResourceFinder(dialogFragment);
    final Drawable resource = mock(Drawable.class);
    final Resources resources = mock(Resources.class);
    final Context context = mock(Context.class);
    when(dialogFragment.getContext()).thenReturn(context);
    when(dialogFragment.getResources()).thenReturn(resources);
    when(resources.getDrawable(resourceId)).thenReturn(resource);
    assertEquals(resource, resourceFinder.getDrawable(resourceId));
}