@Override public Dialog getDialog(DialogFragment dialogFragment) { return dialogFragment.getDialog(); }
/** * Creates a builder for a material tap target prompt that uses an explicit theme resource. * <p> * The {@code themeResId} may be specified as {@code 0} to use the parent {@code context}'s * resolved value for {@link R.attr#MaterialTapTargetPromptTheme}. * * @param dialogFragment the dialog fragment to show the prompt within. * @param themeResId the resource ID of the theme against which to inflate this dialog, * or {@code 0} to use the parent {@code context}'s default material * tap target prompt theme * @deprecated use support library fragments instead */ @Deprecated public Builder(@NonNull final android.app.DialogFragment dialogFragment, int themeResId) { this(dialogFragment.getDialog(), themeResId); }
@Test public void testBuilder_DialogFragment() { final android.app.DialogFragment dialogFragment = spy(Robolectric.buildFragment(android.app.DialogFragment.class).create().get()); final Activity activity = Robolectric.buildActivity(Activity.class).create().get(); final Dialog dialog = mock(Dialog.class); when(dialogFragment.getDialog()).thenReturn(dialog); when(dialog.getOwnerActivity()).thenReturn(activity); when(dialog.findViewById(android.R.id.content)).thenReturn(activity.findViewById(android.R.id.content)); final MaterialTapTargetPrompt.Builder builder = new MaterialTapTargetPrompt.Builder(dialogFragment); assertTrue(builder.getResourceFinder() instanceof DialogResourceFinder); }
@Override public FractionInputDialog getDialog() { return (FractionInputDialog) super.getDialog(); }
/** * Shows the soft keyboard for the given <var>dialogFragment</var>. * * @param dialogFragment The dialog fragment for which window to request keyboard showing. * @return {@code True} if keyboard has been showed, {@code false} otherwise. * @see #hideSoftKeyboard(DialogFragment) */ public static boolean showSoftKeyboard(@NonNull DialogFragment dialogFragment) { if (dialogFragment.isAdded()) { final Dialog dialog = dialogFragment.getDialog(); if (dialog != null) { dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE ); return true; } } return false; }
/** * Hides the soft keyboard for the given <var>dialogFragment</var>. * * @param dialogFragment The dialog fragment for which window to request keyboard hiding. * @return {@code True} if keyboard has been hided, {@code false} otherwise. * @see #showSoftKeyboard(DialogFragment) */ public static boolean hideSoftKeyboard(@NonNull DialogFragment dialogFragment) { if (dialogFragment.isAdded()) { final Dialog dialog = dialogFragment.getDialog(); if (dialog != null) { dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN ); return true; } } return false; }
/** * Shows the soft keyboard for the given <var>dialogFragment</var>. * * @param dialogFragment The dialog fragment for which window to request keyboard showing. * @return {@code True} if keyboard has been showed, {@code false} otherwise. * @see #hideSoftKeyboard(DialogFragment) */ public static boolean showSoftKeyboard(@NonNull DialogFragment dialogFragment) { if (dialogFragment.isAdded()) { final Dialog dialog = dialogFragment.getDialog(); if (dialog != null) { dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE ); return true; } } return false; }
/** * Hides the soft keyboard for the given <var>dialogFragment</var>. * * @param dialogFragment The dialog fragment for which window to request keyboard hiding. * @return {@code True} if keyboard has been hided, {@code false} otherwise. * @see #showSoftKeyboard(DialogFragment) */ public static boolean hideSoftKeyboard(@NonNull DialogFragment dialogFragment) { if (dialogFragment.isAdded()) { final Dialog dialog = dialogFragment.getDialog(); if (dialog != null) { dialog.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN ); return true; } } return false; }