Package eltos.simpledialogfragment.input
Class SimpleInputDialog
java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
eltos.simpledialogfragment.SimpleDialog<This>
eltos.simpledialogfragment.CustomViewDialog<SimpleInputDialog>
eltos.simpledialogfragment.input.SimpleInputDialog
- All Implemented Interfaces:
android.content.ComponentCallbacks
,android.content.DialogInterface.OnCancelListener
,android.content.DialogInterface.OnDismissListener
,android.view.View.OnCreateContextMenuListener
,androidx.activity.result.ActivityResultCaller
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
- Direct Known Subclasses:
SimpleEMailDialog
An simple dialog with an input field. Supports suggestions, input validations and
max length options.
Results:
TEXT String The entered text
Created by eltos on 14.10.2015.
-
Nested Class Summary
Nested classes/interfaces inherited from class eltos.simpledialogfragment.SimpleDialog
SimpleDialog.OnDialogResultListener
Nested classes/interfaces inherited from class androidx.fragment.app.Fragment
androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final String
protected static final String
static final String
static final String
Fields inherited from class eltos.simpledialogfragment.SimpleDialog
BUNDLE, CANCELABLE, FULLSCREEN, HTML, ICON_RESOURCE, MESSAGE, NEGATIVE_BUTTON_TEXT, NEUTRAL_BUTTON_TEXT, POSITIVE_BUTTON_TEXT, THEME, TITLE
Fields inherited from class androidx.fragment.app.DialogFragment
STYLE_NO_FRAME, STYLE_NO_INPUT, STYLE_NO_TITLE, STYLE_NORMAL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Overwrite this method to catch positive button presses, e.g. if you need to verify input by the user Note: do not callCustomViewDialog.pressPositiveButton()
here!allowEmpty
(boolean allow) Allow empty input.static SimpleInputDialog
build()
getText()
hint
(int hintResourceId) Sets the EditText's hintSets the EditText's hintinputType
(int inputType) Sets the input type The default isInputType.TYPE_CLASS_TEXT
.boolean
max
(int maxLength) Sets a max limit to the EditText.android.view.View
onCreateContentView
(android.os.Bundle savedInstanceState) Inflate your custom view here.protected void
Overwrite this method to take action once the dialog is shown such as settings an input focus, showing the keyboard or setting the initial positiveButtonStateandroid.os.Bundle
onResult
(int which) Overwrite this method to provide additional results from your custom view to be passed to theSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
void
onSaveInstanceState
(android.os.Bundle outState) protected String
onValidateInput
(String input) void
Helper for opening the soft keyboardprotected boolean
suggest
(android.content.Context context, int[] stringResourceIds) Provide an array of suggestions to be shown while the user is typingProvide an array of suggestions to be shown while the user is typingtext
(int textResourceId) Sets the EditText's initial textSets the EditText's initial textMethods inherited from class eltos.simpledialogfragment.CustomViewDialog
callResultListener, extractContentView, inflate, inflate, onCreate, onCreateDialog, onNegativeButtonClick, onNeutralButtonClick, onPositiveButtonClick, pressPositiveButton, setNegativeButtonEnabled, setNeutralButtonEnabled, setPositiveButtonEnabled
Methods inherited from class eltos.simpledialogfragment.SimpleDialog
cancelable, extra, fullscreen, fullscreen, getArgs, getArgString, getContext, getExtras, getMessage, getTitle, icon, isCancelable, msg, msg, msgHtml, msgHtml, neg, neg, neg, neut, neut, neut, onCancel, onDestroyView, pos, pos, setArg, setArg, setArg, setArg, setButtonClickListener, setButtonEnabled, show, show, show, show, show, show, show, show, showKeyboard, theme, title, title
Methods inherited from class androidx.fragment.app.DialogFragment
dismiss, dismissAllowingStateLoss, getDialog, getShowsDialog, getTheme, onAttach, onDetach, onDismiss, onGetLayoutInflater, onStart, onStop, onViewStateRestored, requireDialog, setCancelable, setShowsDialog, setStyle, setupDialog, showNow
Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onViewCreated, postponeEnterTransition, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface androidx.lifecycle.HasDefaultViewModelProviderFactory
getDefaultViewModelCreationExtras
-
Field Details
-
TAG
- See Also:
-
TEXT
- See Also:
-
HINT
- See Also:
-
INPUT_TYPE
- See Also:
-
ALLOW_EMPTY
- See Also:
-
MAX_LENGTH
- See Also:
-
SUGGESTIONS
- See Also:
-
-
Constructor Details
-
SimpleInputDialog
public SimpleInputDialog()
-
-
Method Details
-
build
-
hint
Sets the EditText's hint- Parameters:
hint
- the hint as string- Returns:
- this instance
-
hint
Sets the EditText's hint- Parameters:
hintResourceId
- the hint as android string resource- Returns:
- this instance
-
text
Sets the EditText's initial text- Parameters:
text
- initial text as string- Returns:
- this instance
-
text
Sets the EditText's initial text- Parameters:
textResourceId
- initial text as android string resource- Returns:
- this instance
-
inputType
Sets the input type The default isInputType.TYPE_CLASS_TEXT
.- Parameters:
inputType
- the InputType- Returns:
- this instance
-
allowEmpty
Allow empty input. Default is to disable the positive button until text is entered.- Parameters:
allow
- whether to allow empty input- Returns:
- this instance
-
max
Sets a max limit to the EditText.- Parameters:
maxLength
- the maximum text length- Returns:
- this instance
-
suggest
Provide an array of suggestions to be shown while the user is typing- Parameters:
context
- a context to resolve the resource idsstringResourceIds
- suggestion array as android string resources- Returns:
- this instance
-
suggest
Provide an array of suggestions to be shown while the user is typing- Parameters:
strings
- suggestion string array- Returns:
- this instance
-
onValidateInput
-
getText
- Returns:
- the current text or null
-
isInputEmpty
public boolean isInputEmpty() -
openKeyboard
public void openKeyboard()Helper for opening the soft keyboard -
onCreateContentView
public android.view.View onCreateContentView(android.os.Bundle savedInstanceState) Description copied from class:CustomViewDialog
Inflate your custom view here.- Specified by:
onCreateContentView
in classCustomViewDialog<SimpleInputDialog>
- Parameters:
savedInstanceState
- The last saved instance state of the Fragment, or null if this fragment is created for the first time.- Returns:
- Return a new View to be displayed by the Fragment.
-
posEnabled
protected boolean posEnabled() -
onDialogShown
protected void onDialogShown()Description copied from class:CustomViewDialog
Overwrite this method to take action once the dialog is shown such as settings an input focus, showing the keyboard or setting the initial positiveButtonState- Overrides:
onDialogShown
in classCustomViewDialog<SimpleInputDialog>
-
acceptsPositiveButtonPress
protected boolean acceptsPositiveButtonPress()Description copied from class:CustomViewDialog
Overwrite this method to catch positive button presses, e.g. if you need to verify input by the user Note: do not callCustomViewDialog.pressPositiveButton()
here!- Overrides:
acceptsPositiveButtonPress
in classCustomViewDialog<SimpleInputDialog>
- Returns:
- false to ignore the press, true to process normally
-
onResult
public android.os.Bundle onResult(int which) Description copied from class:CustomViewDialog
Overwrite this method to provide additional results from your custom view to be passed to theSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
- Overrides:
onResult
in classCustomViewDialog<SimpleInputDialog>
- Parameters:
which
- seeSimpleDialog.OnDialogResultListener
- Returns:
- the bundle to merge with the results or null
-
onSaveInstanceState
public void onSaveInstanceState(android.os.Bundle outState) - Overrides:
onSaveInstanceState
in classandroidx.fragment.app.DialogFragment
-