Class ThemeFragment<T extends DynamicAppTheme>
java.lang.Object
androidx.fragment.app.Fragment
com.pranavpandey.android.dynamic.support.fragment.DynamicFragment
com.pranavpandey.android.dynamic.support.theme.fragment.ThemeFragment<T>
- Type Parameters:
T
- The type of the dynamic app theme this fragment will handle.
- All Implemented Interfaces:
ComponentCallbacks
,SharedPreferences.OnSharedPreferenceChangeListener
,View.OnCreateContextMenuListener
,ActivityResultCaller
,MenuProvider
,HasDefaultViewModelProviderFactory
,LifecycleOwner
,ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
,DynamicLifecycle
,DynamicSearchListener
,DynamicTransitionListener
,ThemeListener<T>
,ThemeListener.Export<T>
,ThemeListener.Import<T>
,ThemeListener.Value
,DynamicProductFlavor
- Direct Known Subclasses:
DynamicRemoteThemeFragment
,DynamicThemeFragment
public abstract class ThemeFragment<T extends DynamicAppTheme>
extends DynamicFragment
implements ThemeListener.Value, ThemeListener.Import<T>, ThemeListener.Export<T>
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 T
Dynamic app theme used by this fragment.protected T
Default dynamic app theme used by this fragment.protected DynamicDialogFragment
Dialog fragment to show the progress.protected boolean
true
if the settings have been changed.protected Uri
Temporary file URI to store the exported theme.protected ThemePreview<T>
Theme preview used by this fragment.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
getPreferenceValue
(DynamicSliderPreference preference, int fallback) Try to resolve theme value from the slider preference.int
getPreferenceValue
(DynamicSpinnerPreference preference, int fallback) Try to resolve theme value from the spinner preference.This method will be called to get the share title.int
getStyle()
Returns the resolved style for the theme.getThemeBitmap
(ThemePreview<T> themePreview, int themeAction) This method will be called to return a bitmap.DynamicTask<?,
?, ?> getThemeExportTask
(DialogInterface dialog, int themeAction, ThemePreview<T> themePreview) This method will be called to get the theme export task.Get the theme preview associated with this listener.void
importTheme
(int themeAction) This method will be called on importing the theme.void
importTheme
(String theme) This method will be called on importing the theme.void
importTheme
(String theme, int themeAction) This method will be called on importing the theme.void
onActivityResult
(int requestCode, int resultCode, Intent data) void
onCreateMenu
(Menu menu, MenuInflater inflater) boolean
onMenuItemSelected
(MenuItem item) void
onPrepareMenu
(Menu menu) void
onThemeError
(int themeAction, ThemePreview<T> themePreview, Exception e) This method will be called on error while doing theme operations.protected void
Save theme according to the supplied parameters.void
Set the theme and finish this activity.protected void
setProgress
(int requestCode, boolean visible) Set progress for the theme tasks.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, isOnSharedPreferenceChangeListener, isSearchViewExpanded, isSearchViewListenerListener, isSupportActionBar, onAddActivityHeader, onAddMenuProvider, onAdjustEnterReturnTransition, onAdjustExitReenterTransition, onApplyTransitions, onCreate, onDestroy, onDynamicPause, onDynamicResume, onFindView, onMenuClosed, onPause, onRemoveProvider, onResume, onSaveInstanceState, onSearchViewCollapsed, onSearchViewExpanded, onSharedPreferenceChanged, onStart, onStartActivityException, onViewCreated, postponeEnterTransition, setHasOptionsMenu, 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, onCreateView, 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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.pranavpandey.android.dynamic.support.theme.listener.ThemeListener
onLoadTheme, onSetAction
Methods inherited from interface com.pranavpandey.android.dynamic.support.theme.listener.ThemeListener.Import
onImportTheme
-
Field Details
-
mDynamicTheme
Dynamic app theme used by this fragment. -
mDynamicThemeDefault
Default dynamic app theme used by this fragment. -
mThemeExported
Temporary file URI to store the exported theme. -
mSettingsChanged
protected boolean mSettingsChangedtrue
if the settings have been changed. -
mThemePreview
Theme preview used by this fragment. -
mProgressDialog
Dialog fragment to show the progress.
-
-
Constructor Details
-
ThemeFragment
public ThemeFragment()
-
-
Method Details
-
onCreateMenu
- Specified by:
onCreateMenu
in interfaceMenuProvider
- Overrides:
onCreateMenu
in classDynamicFragment
-
onPrepareMenu
- Specified by:
onPrepareMenu
in interfaceMenuProvider
- Overrides:
onPrepareMenu
in classDynamicFragment
-
onMenuItemSelected
- Specified by:
onMenuItemSelected
in interfaceMenuProvider
- Overrides:
onMenuItemSelected
in classDynamicFragment
-
saveTheme
Save theme according to the supplied parameters.- Parameters:
requestCode
- The request code to be used.file
- The file URI to be used.
-
onActivityResult
- Overrides:
onActivityResult
in classFragment
-
setProgress
protected void setProgress(int requestCode, boolean visible) Set progress for the theme tasks.- Parameters:
requestCode
- The request code to be used.visible
-true
to make the progress visible.
-
getFontScale
public int getFontScale()Description copied from interface:ThemeListener.Value
Returns the resolved font scale for the theme.- Specified by:
getFontScale
in interfaceThemeListener.Value
- 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
- 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
- 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
- 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
- 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
- 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
- Returns:
- The resolved style for the theme.
-
getThemePreview
Description copied from interface:ThemeListener
Get the theme preview associated with this listener.- Specified by:
getThemePreview
in interfaceThemeListener<T extends DynamicAppTheme>
- Returns:
- The theme preview associated with this listener.
-
importTheme
public void importTheme(int themeAction) Description copied from interface:ThemeListener.Import
This method will be called on importing the theme.- Specified by:
importTheme
in interfaceThemeListener.Import<T extends DynamicAppTheme>
- Parameters:
themeAction
- The theme action to be used.
-
importTheme
Description copied from interface:ThemeListener.Import
This method will be called on importing the theme.- Specified by:
importTheme
in interfaceThemeListener.Import<T extends DynamicAppTheme>
- Parameters:
theme
- The theme string to be imported.
-
importTheme
Description copied from interface:ThemeListener.Import
This method will be called on importing the theme.- Specified by:
importTheme
in interfaceThemeListener.Import<T extends DynamicAppTheme>
- Parameters:
theme
- The theme string to be imported.themeAction
- The theme action to be used.
-
saveThemeSettings
public void saveThemeSettings()Set the theme and finish this activity.