Package eltos.simpledialogfragment.color
Class SimpleColorDialog
java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
eltos.simpledialogfragment.SimpleDialog<This>
eltos.simpledialogfragment.CustomViewDialog<This>
eltos.simpledialogfragment.list.CustomListDialog<SimpleColorDialog>
eltos.simpledialogfragment.color.SimpleColorDialog
- All Implemented Interfaces:
android.content.ComponentCallbacks
,android.content.DialogInterface.OnCancelListener
,android.content.DialogInterface.OnDismissListener
,android.view.View.OnCreateContextMenuListener
,android.widget.AdapterView.OnItemClickListener
,android.widget.AdapterView.OnItemLongClickListener
,androidx.activity.result.ActivityResultCaller
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
,SimpleDialog.OnDialogResultListener
public class SimpleColorDialog
extends CustomListDialog<SimpleColorDialog>
implements SimpleDialog.OnDialogResultListener
A dialog that let's the user select a color
Result:
COLOR int Selected color (rgb)
Created by eltos on 17.04.2016.
-
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 TypeFieldDescriptionstatic final int
static final int
static final String
static final int
static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
static final int[]
static final int
static final int
static final int
static final int
protected static final int
protected static final String
static final String
Fields inherited from class eltos.simpledialogfragment.list.CustomListDialog
CHOICE_MAX_COUNT, CHOICE_MIN_COUNT, CHOICE_MODE, INITIALLY_CHECKED_IDS, INITIALLY_CHECKED_POSITIONS, mAdapter, mFilterEditText, mListView, MULTI_CHOICE, NO_CHOICE, SELECTED_IDS, SELECTED_POSITIONS, SELECTED_SINGLE_ID, SELECTED_SINGLE_POSITION, SINGLE_CHOICE, SINGLE_CHOICE_DIRECT
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
Fields inherited from interface eltos.simpledialogfragment.SimpleDialog.OnDialogResultListener
BUTTON_NEGATIVE, BUTTON_NEUTRAL, BUTTON_POSITIVE, CANCELED
-
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!allowCustom
(boolean allow) Set this to true to show a field with a color picker optionstatic SimpleColorDialog
build()
colorPreset
(int color) Sets the initially selected colorcolors
(int[] colors) Sets the colors to choose from Default is theDEFAULT_COLORS
setcolors
(android.content.Context context, int colorArrayRes) Sets the color pallet to choose from May be one ofMATERIAL_COLOR_PALLET
,MATERIAL_COLOR_PALLET_DARK
,MATERIAL_COLOR_PALLET_LIGHT
,BEIGE_COLOR_PALLET
or a custom palletvoid
onCreate
(android.os.Bundle savedInstanceState) protected AdvancedAdapter
Overwrite this method to provide a custom adaptervoid
onItemClick
(android.widget.AdapterView<?> parent, android.view.View view, int position, long id) Callback method to be invoked when an item in this AdapterView has been clicked.protected android.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)
boolean
Let the hosting fragment or activity implement this interface to receive results from the dialogvoid
onSaveInstanceState
(android.os.Bundle outState) setupColorWheelAlpha
(boolean alpha) ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleColorWheelDialog.alpha(boolean)
setupColorWheelHideHex
(boolean hideHex) ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleColorWheelDialog.hideHexInput(boolean)
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleDialog.neut(CharSequence)
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleDialog.pos(CharSequence)
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleDialog.title(CharSequence)
showOutline
(int color) Add a colored outline to the color fields.Methods inherited from class eltos.simpledialogfragment.list.CustomListDialog
choiceIdPreset, choiceIdPreset, choiceIdPreset, choiceMax, choiceMin, choiceMode, choicePreset, choicePreset, choicePreset, divider, emptyText, emptyText, filterable, getListView, grid, gridColumnWidth, gridNumColumn, notifyDataSetChanged, onCreateContentView, onDialogShown, onItemLongClick, pos, pos, updatePosButton
Methods inherited from class eltos.simpledialogfragment.CustomViewDialog
callResultListener, extractContentView, inflate, inflate, 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, 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:
-
COLOR
- See Also:
-
COLORS
- See Also:
-
MATERIAL_COLOR_PALLET
@ArrayRes public static final int MATERIAL_COLOR_PALLET -
MATERIAL_COLOR_PALLET_LIGHT
@ArrayRes public static final int MATERIAL_COLOR_PALLET_LIGHT -
MATERIAL_COLOR_PALLET_DARK
@ArrayRes public static final int MATERIAL_COLOR_PALLET_DARK -
BEIGE_COLOR_PALLET
@ArrayRes public static final int BEIGE_COLOR_PALLET -
COLORFUL_COLOR_PALLET
@ArrayRes public static final int COLORFUL_COLOR_PALLET -
NONE
public static final int NONE- See Also:
-
AUTO
public static final int AUTO- See Also:
-
DEFAULT_COLORS
@ColorInt public static final int[] DEFAULT_COLORS -
PICKER
protected static final int PICKER- See Also:
-
PICKER_DIALOG_TAG
- See Also:
-
CUSTOM
- See Also:
-
CUSTOM_ALPHA
- See Also:
-
CUSTOM_HIDE_HEX
- See Also:
-
CUSTOM_TITLE
- See Also:
-
CUSTOM_POS
- See Also:
-
CUSTOM_NEUT
- See Also:
-
-
Constructor Details
-
SimpleColorDialog
public SimpleColorDialog()
-
-
Method Details
-
build
-
colors
Sets the colors to choose from Default is theDEFAULT_COLORS
set- Parameters:
colors
- array of rgb-colors- Returns:
- this instance
-
colors
Sets the color pallet to choose from May be one ofMATERIAL_COLOR_PALLET
,MATERIAL_COLOR_PALLET_DARK
,MATERIAL_COLOR_PALLET_LIGHT
,BEIGE_COLOR_PALLET
or a custom pallet- Parameters:
context
- a context to resolve the resourcecolorArrayRes
- color array resource id- Returns:
- this instance
-
colorPreset
Sets the initially selected color- Parameters:
color
- the selected color- Returns:
- this instance
-
allowCustom
Set this to true to show a field with a color picker option- Parameters:
allow
- allow custom picked color if true- Returns:
- this instance
-
setupColorWheelAlpha
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleColorWheelDialog.alpha(boolean)
- Parameters:
alpha
- whether or not to allow transparency (alpha) adjustment- Returns:
- this instance
-
setupColorWheelHideHex
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleColorWheelDialog.hideHexInput(boolean)
- Parameters:
hideHex
- whether or not to hide the input field- Returns:
- this instance
-
setupColorWheelTitle
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleDialog.title(CharSequence)
- Parameters:
text
- the title for the color wheel dialog- Returns:
- this instance
-
setupColorWheelPosButton
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleDialog.pos(CharSequence)
- Parameters:
text
- the positive button text for the color wheel dialog- Returns:
- this instance
-
setupColorWheelNeutButton
ConfiguresSimpleColorWheelDialog
for custom color picking SeeSimpleDialog.neut(CharSequence)
- Parameters:
text
- the neutral button text for the color wheel dialog- Returns:
- this instance
-
showOutline
-
onCreate
public void onCreate(android.os.Bundle savedInstanceState) - Overrides:
onCreate
in classCustomViewDialog<SimpleColorDialog>
-
onCreateAdapter
Description copied from class:CustomListDialog
Overwrite this method to provide a custom adapter- Specified by:
onCreateAdapter
in classCustomListDialog<SimpleColorDialog>
- Returns:
- the ListAdapter to use
-
onSaveInstanceState
public void onSaveInstanceState(android.os.Bundle outState) - Overrides:
onSaveInstanceState
in classCustomListDialog<SimpleColorDialog>
-
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<SimpleColorDialog>
- Returns:
- false to ignore the press, true to process normally
-
onItemClick
public void onItemClick(android.widget.AdapterView<?> parent, android.view.View view, int position, long id) Description copied from class:CustomListDialog
Callback method to be invoked when an item in this AdapterView has been clicked. Implementers can call Adapter#getItem(position) if they need to access the data associated with the selected item.- Specified by:
onItemClick
in interfaceandroid.widget.AdapterView.OnItemClickListener
- Overrides:
onItemClick
in classCustomListDialog<SimpleColorDialog>
- Parameters:
parent
- The AdapterView where the click happened.view
- The view within the AdapterView that was clicked (this will be a view provided by the adapter)position
- The position of the view in the adapter.id
- The row id of the item that was clicked.
-
onResult
Description copied from interface:SimpleDialog.OnDialogResultListener
Let the hosting fragment or activity implement this interface to receive results from the dialog- Specified by:
onResult
in interfaceSimpleDialog.OnDialogResultListener
- Parameters:
dialogTag
- the tag passed toSimpleDialog.show(androidx.fragment.app.Fragment)
which
- result type, one ofSimpleDialog.OnDialogResultListener.BUTTON_POSITIVE
,SimpleDialog.OnDialogResultListener.BUTTON_NEGATIVE
,SimpleDialog.OnDialogResultListener.BUTTON_NEUTRAL
orSimpleDialog.OnDialogResultListener.CANCELED
extras
- the extras passed toSimpleDialog.extra(Bundle)
- Returns:
- true if the result was handled, false otherwise
-
onResult
protected 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 classCustomListDialog<SimpleColorDialog>
- Parameters:
which
- seeSimpleDialog.OnDialogResultListener
- Returns:
- the bundle to merge with the results or null
-