Class DynamicRemoteThemeFragment
java.lang.Object
androidx.fragment.app.Fragment
com.pranavpandey.android.dynamic.support.fragment.DynamicFragment
com.pranavpandey.android.dynamic.support.theme.fragment.ThemeFragment<DynamicRemoteTheme>
com.pranavpandey.android.dynamic.support.theme.fragment.DynamicRemoteThemeFragment
- All Implemented Interfaces:
ComponentCallbacks
,SharedPreferences.OnSharedPreferenceChangeListener
,View.OnCreateContextMenuListener
,ActivityResultCaller
,MenuProvider
,HasDefaultViewModelProviderFactory
,LifecycleOwner
,ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
,DynamicLifecycle
,DynamicSearchListener
,DynamicTransitionListener
,ThemeListener<DynamicRemoteTheme>
,ThemeListener.Export<DynamicRemoteTheme>
,ThemeListener.Import<DynamicRemoteTheme>
,ThemeListener.Value
,DynamicProductFlavor
Base theme fragment to provide theme editing functionality.
Extend this fragment to implement theme attributes according to the requirements.
-
Nested Class Summary
Nested classes/interfaces inherited from class androidx.fragment.app.Fragment
Fragment.InstantiationException, Fragment.SavedState
Nested classes/interfaces inherited from interface com.pranavpandey.android.dynamic.support.theme.listener.ThemeListener
ThemeListener.Code, ThemeListener.Export<T extends DynamicAppTheme>, ThemeListener.Import<T extends DynamicAppTheme>, ThemeListener.Select, ThemeListener.Value
Nested classes/interfaces inherited from interface com.pranavpandey.android.dynamic.support.theme.listener.ThemeListener.Import
ThemeListener.Import.File<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected DynamicSpinnerPreference
Dynamic spinner preference to control the background aware functionality.protected DynamicColorPreference
Dynamic color preference to control the dark accent colors.protected DynamicColorPreference
Dynamic color preference to control the accent colors.protected DynamicColorPreference
Dynamic color preference to control the background colors.protected DynamicColorPreference
Dynamic color preference to control the error colors.protected DynamicColorPreference
Dynamic color preference to control the dark primary colors.protected DynamicColorPreference
Dynamic color preference to control the primary colors.protected DynamicColorPreference
Dynamic color preference to control the surface colors.protected DynamicSliderPreference
Dynamic slider preference to control the contrast.protected DynamicSliderPreference
Dynamic slider preference to control the corner radius.protected DynamicSpinnerPreference
Dynamic spinner preference to control the elevation functionality.protected DynamicSliderPreference
Dynamic slider preference to control the font scale.protected DynamicSliderPreference
Dynamic slider preference to control the opacity.protected DynamicPresetsView<DynamicRemoteTheme>
View to show the theme presets.protected DynamicSpinnerPreference
Dynamic spinner preference to control the style functionality.protected DynamicColorPreference
Dynamic color preference to control the primary text colors.protected DynamicColorPreference
Dynamic color preference to control the secondary text colors.Fields inherited from class com.pranavpandey.android.dynamic.support.theme.fragment.ThemeFragment
mDynamicTheme, mDynamicThemeDefault, mProgressDialog, mSettingsChanged, mThemeExported, mThemePreview
Fields inherited from class androidx.fragment.app.Fragment
mPreviousWho
Fields inherited from interface com.pranavpandey.android.dynamic.support.theme.listener.ThemeListener
ADS_NAME_THEME_PREVIEW, ADS_NAME_THEME_PREVIEW_ACTION, ADS_NAME_THEME_PREVIEW_ICON, ADS_PREF_THEME_BACKGROUND_AWARE, ADS_PREF_THEME_COLOR_ACCENT, ADS_PREF_THEME_COLOR_ACCENT_DARK, ADS_PREF_THEME_COLOR_BACKGROUND, ADS_PREF_THEME_COLOR_ERROR, ADS_PREF_THEME_COLOR_PRIMARY, ADS_PREF_THEME_COLOR_PRIMARY_DARK, ADS_PREF_THEME_COLOR_SURFACE, ADS_PREF_THEME_COLOR_TINT_ACCENT, ADS_PREF_THEME_COLOR_TINT_ACCENT_DARK, ADS_PREF_THEME_COLOR_TINT_BACKGROUND, ADS_PREF_THEME_COLOR_TINT_ERROR, ADS_PREF_THEME_COLOR_TINT_PRIMARY, ADS_PREF_THEME_COLOR_TINT_PRIMARY_DARK, ADS_PREF_THEME_COLOR_TINT_SURFACE, ADS_PREF_THEME_CONTRAST, ADS_PREF_THEME_CONTRAST_ALT, ADS_PREF_THEME_CORNER_SIZE, ADS_PREF_THEME_CORNER_SIZE_ALT, ADS_PREF_THEME_ELEVATION, ADS_PREF_THEME_FONT_SCALE, ADS_PREF_THEME_FONT_SCALE_ALT, ADS_PREF_THEME_OPACITY, ADS_PREF_THEME_OPACITY_ALT, ADS_PREF_THEME_STYLE, ADS_PREF_THEME_TEXT_INVERSE_PRIMARY, ADS_PREF_THEME_TEXT_INVERSE_SECONDARY, ADS_PREF_THEME_TEXT_PRIMARY, ADS_PREF_THEME_TEXT_SECONDARY, REQUEST_THEME_CAPTURE, REQUEST_THEME_CODE_LOCATION, REQUEST_THEME_CODE_LOCATION_ALT, REQUEST_THEME_IMPORT, REQUEST_THEME_LOCATION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the resolved background aware for the theme.int
Returns the resolved contrast for the theme.int
Returns the resolved corner size for the theme.int
Returns the resolved elevation for the theme.int
Returns the resolved font scale for the theme.int
Returns the resolved opacity for the theme.int
getStyle()
Returns the resolved style for the theme.getThemeBitmap
(ThemePreview<DynamicRemoteTheme> themePreview, int themeAction) This method will be called to return a bitmap.Retrieves the theme from the supplies argumentsboolean
Returns whether to register a shared preferences listener for this fragment.static DynamicRemoteThemeFragment
newInstance
(String DynamicRemoteTheme, String DynamicRemoteThemeDefault) Initialize the new instance of this fragment.static DynamicRemoteThemeFragment
newInstance
(String DynamicRemoteTheme, String DynamicRemoteThemeDefault, boolean showPresets) Initialize the new instance of this fragment.void
onCreateView
(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) onImportTheme
(String theme) This method will be called on importing the theme.void
onLoadTheme
(DynamicRemoteTheme theme) This method will called to load settings from the supplied theme.void
onResume()
void
onSetAction
(int themeAction, ThemePreview<DynamicRemoteTheme> themePreview, boolean enable) This method will be called on setting the action icon.void
onSharedPreferenceChanged
(SharedPreferences sharedPreferences, String key) void
onViewCreated
(View view, Bundle savedInstanceState) boolean
Returns whether to set the options menu for this fragment.Methods inherited from class com.pranavpandey.android.dynamic.support.theme.fragment.ThemeFragment
getPreferenceValue, getPreferenceValue, getShareTitle, getThemeExportTask, getThemePreview, importTheme, importTheme, importTheme, onActivityResult, onCreateMenu, onMenuItemSelected, onPrepareMenu, onThemeError, saveTheme, saveThemeSettings, setProgress
Methods inherited from class com.pranavpandey.android.dynamic.support.fragment.DynamicFragment
finishActivity, getBooleanFromArguments, getCheckedMenuItemId, getDynamicActivity, getDynamicEnterTransition, getDynamicExitTransition, getDynamicReenterTransition, getDynamicReturnTransition, getHostMenu, getIntFromArguments, getNavigationViewId, getParcelableFromArguments, getPostponeTransitionView, getProductFlavor, getSavedInstanceState, getStringFromArguments, getStringFromArguments, getSubtitle, getSystemActivity, getTextWatcher, getTitle, invalidateHostMenu, isAppCompatActivity, isEnableMenu, isForceMenuIcons, isHasMenuProvider, isSearchViewExpanded, isSearchViewListenerListener, isSupportActionBar, onAddActivityHeader, onAddMenuProvider, onAdjustEnterReturnTransition, onAdjustExitReenterTransition, onApplyTransitions, onDestroy, onDynamicPause, onDynamicResume, onFindView, onMenuClosed, onPause, onRemoveProvider, onSaveInstanceState, onSearchViewCollapsed, onSearchViewExpanded, onStart, onStartActivityException, postponeEnterTransition, setHostMenuItemVisible, setMenuVisibility, setResult, setResult, setResult, setResult, startActivity, startActivity, startActivityForResult, startActivityForResult, startMotionActivity, startMotionActivityForResult, startPostponedEnterTransition
Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getDefaultViewModelCreationExtras, 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, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onStop, onViewStateRestored, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startIntentSenderForResult, toString, unregisterForContextMenu
-
Field Details
-
mPresetsView
View to show the theme presets. -
mColorBackgroundPreference
Dynamic color preference to control the background colors. -
mColorSurfacePreference
Dynamic color preference to control the surface colors. -
mColorPrimaryPreference
Dynamic color preference to control the primary colors. -
mColorAccentPreference
Dynamic color preference to control the accent colors. -
mColorPrimaryDarkPreference
Dynamic color preference to control the dark primary colors. -
mColorAccentDarkPreference
Dynamic color preference to control the dark accent colors. -
mColorErrorPreference
Dynamic color preference to control the error colors. -
mTextPrimaryPreference
Dynamic color preference to control the primary text colors. -
mTextSecondaryPreference
Dynamic color preference to control the secondary text colors. -
mFontScalePreference
Dynamic slider preference to control the font scale. -
mCornerSizePreference
Dynamic slider preference to control the corner radius. -
mBackgroundAwarePreference
Dynamic spinner preference to control the background aware functionality. -
mContrastPreference
Dynamic slider preference to control the contrast. -
mOpacityPreference
Dynamic slider preference to control the opacity. -
mElevationPreference
Dynamic spinner preference to control the elevation functionality. -
mStylePreference
Dynamic spinner preference to control the style functionality.
-
-
Constructor Details
-
DynamicRemoteThemeFragment
public DynamicRemoteThemeFragment()
-
-
Method Details
-
newInstance
@NonNull public static DynamicRemoteThemeFragment newInstance(@Nullable String DynamicRemoteTheme, @Nullable String DynamicRemoteThemeDefault) Initialize the new instance of this fragment.- Parameters:
DynamicRemoteTheme
- The dynamic app theme.DynamicRemoteThemeDefault
- The default dynamic app theme.- Returns:
- An instance of
DynamicRemoteThemeFragment
. - See Also:
-
newInstance
@NonNull public static DynamicRemoteThemeFragment newInstance(@Nullable String DynamicRemoteTheme, @Nullable String DynamicRemoteThemeDefault, boolean showPresets) Initialize the new instance of this fragment.- Parameters:
DynamicRemoteTheme
- The dynamic app theme.DynamicRemoteThemeDefault
- The default dynamic app theme.showPresets
-true
to show the presets.- Returns:
- An instance of
DynamicRemoteThemeFragment
.
-
onCreate
- Overrides:
onCreate
in classDynamicFragment
-
onCreateView
@Nullable public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) - Overrides:
onCreateView
in classFragment
-
onViewCreated
- Overrides:
onViewCreated
in classDynamicFragment
-
setHasOptionsMenu
public boolean setHasOptionsMenu()Description copied from class:DynamicFragment
Returns whether to set the options menu for this fragment.- Overrides:
setHasOptionsMenu
in classDynamicFragment
- Returns:
true
if set the options menu for this fragment.- See Also:
-
onResume
public void onResume()- Overrides:
onResume
in classDynamicFragment
-
getThemeFromArguments
Retrieves the theme from the supplies arguments- Parameters:
key
- The key to be retrieved.- Returns:
- The dynamic theme from the supplied arguments.
-
onImportTheme
Description copied from interface:ThemeListener.Import
This method will be called on importing the theme.- Parameters:
theme
- The theme string to be imported.- Returns:
- The imported theme.
-
getFontScale
public int getFontScale()Description copied from interface:ThemeListener.Value
Returns the resolved font scale for the theme.- Specified by:
getFontScale
in interfaceThemeListener.Value
- Overrides:
getFontScale
in classThemeFragment<DynamicRemoteTheme>
- Returns:
- The resolved font scale for the theme.
-
getCornerSize
public int getCornerSize()Description copied from interface:ThemeListener.Value
Returns the resolved corner size for the theme.- Specified by:
getCornerSize
in interfaceThemeListener.Value
- Overrides:
getCornerSize
in classThemeFragment<DynamicRemoteTheme>
- Returns:
- The resolved corner size for the theme.
-
getBackgroundAware
public int getBackgroundAware()Description copied from interface:ThemeListener.Value
Returns the resolved background aware for the theme.- Specified by:
getBackgroundAware
in interfaceThemeListener.Value
- Overrides:
getBackgroundAware
in classThemeFragment<DynamicRemoteTheme>
- Returns:
- The resolved background aware for the theme.
-
getContrast
public int getContrast()Description copied from interface:ThemeListener.Value
Returns the resolved contrast for the theme.- Specified by:
getContrast
in interfaceThemeListener.Value
- Overrides:
getContrast
in classThemeFragment<DynamicRemoteTheme>
- Returns:
- The resolved contrast for the theme.
-
getOpacity
public int getOpacity()Description copied from interface:ThemeListener.Value
Returns the resolved opacity for the theme.- Specified by:
getOpacity
in interfaceThemeListener.Value
- Overrides:
getOpacity
in classThemeFragment<DynamicRemoteTheme>
- Returns:
- The resolved opacity for the theme.
-
getElevation
public int getElevation()Description copied from interface:ThemeListener.Value
Returns the resolved elevation for the theme.- Specified by:
getElevation
in interfaceThemeListener.Value
- Overrides:
getElevation
in classThemeFragment<DynamicRemoteTheme>
- Returns:
- The resolved elevation for the theme.
-
getStyle
public int getStyle()Description copied from interface:ThemeListener.Value
Returns the resolved style for the theme.- Specified by:
getStyle
in interfaceThemeListener.Value
- Overrides:
getStyle
in classThemeFragment<DynamicRemoteTheme>
- Returns:
- The resolved style for the theme.
-