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.SavedStateNested 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.ValueNested classes/interfaces inherited from interface com.pranavpandey.android.dynamic.support.theme.listener.ThemeListener.Import
ThemeListener.Import.File<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TDynamic app theme used by this fragment.protected TDefault dynamic app theme used by this fragment.protected DynamicDialogFragmentDialog fragment to show the progress.protected booleantrueif the settings have been changed.protected UriTemporary file URI to store the exported theme.protected ThemePreview<T>Theme preview used by this fragment.Fields inherited from class androidx.fragment.app.Fragment
mPreviousWhoFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the resolved background aware for the theme.intReturns the resolved contrast for the theme.intReturns the resolved corner size for the theme.intReturns the resolved elevation for the theme.intReturns the resolved font scale for the theme.intReturns the resolved opacity for the theme.intgetPreferenceValue(DynamicSliderPreference preference, int fallback) Try to resolve theme value from the slider preference.intgetPreferenceValue(DynamicSpinnerPreference preference, int fallback) Try to resolve theme value from the spinner preference.This method will be called to get the share title.intgetStyle()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.voidimportTheme(int themeAction) This method will be called on importing the theme.voidimportTheme(String theme) This method will be called on importing the theme.voidimportTheme(String theme, int themeAction) This method will be called on importing the theme.voidonActivityResult(int requestCode, int resultCode, Intent data) voidonCreateMenu(Menu menu, MenuInflater inflater) booleanonMenuItemSelected(MenuItem item) voidonPrepareMenu(Menu menu) voidonThemeError(int themeAction, ThemePreview<T> themePreview, Exception e) This method will be called on error while doing theme operations.protected voidSave theme according to the supplied parameters.voidSet the theme and finish this activity.protected voidsetProgress(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, startPostponedEnterTransitionMethods 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, unregisterForContextMenuMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.pranavpandey.android.dynamic.support.theme.listener.ThemeListener
onLoadTheme, onSetActionMethods 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 mSettingsChangedtrueif 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:
onCreateMenuin interfaceMenuProvider- Overrides:
onCreateMenuin classDynamicFragment
-
onPrepareMenu
- Specified by:
onPrepareMenuin interfaceMenuProvider- Overrides:
onPrepareMenuin classDynamicFragment
-
onMenuItemSelected
- Specified by:
onMenuItemSelectedin interfaceMenuProvider- Overrides:
onMenuItemSelectedin 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:
onActivityResultin classFragment
-
setProgress
protected void setProgress(int requestCode, boolean visible) Set progress for the theme tasks.- Parameters:
requestCode- The request code to be used.visible-trueto make the progress visible.
-
getFontScale
public int getFontScale()Description copied from interface:ThemeListener.ValueReturns the resolved font scale for the theme.- Specified by:
getFontScalein interfaceThemeListener.Value- Returns:
- The resolved font scale for the theme.
-
getCornerSize
public int getCornerSize()Description copied from interface:ThemeListener.ValueReturns the resolved corner size for the theme.- Specified by:
getCornerSizein interfaceThemeListener.Value- Returns:
- The resolved corner size for the theme.
-
getBackgroundAware
public int getBackgroundAware()Description copied from interface:ThemeListener.ValueReturns the resolved background aware for the theme.- Specified by:
getBackgroundAwarein interfaceThemeListener.Value- Returns:
- The resolved background aware for the theme.
-
getContrast
public int getContrast()Description copied from interface:ThemeListener.ValueReturns the resolved contrast for the theme.- Specified by:
getContrastin interfaceThemeListener.Value- Returns:
- The resolved contrast for the theme.
-
getOpacity
public int getOpacity()Description copied from interface:ThemeListener.ValueReturns the resolved opacity for the theme.- Specified by:
getOpacityin interfaceThemeListener.Value- Returns:
- The resolved opacity for the theme.
-
getElevation
public int getElevation()Description copied from interface:ThemeListener.ValueReturns the resolved elevation for the theme.- Specified by:
getElevationin interfaceThemeListener.Value- Returns:
- The resolved elevation for the theme.
-
getStyle
public int getStyle()Description copied from interface:ThemeListener.ValueReturns the resolved style for the theme.- Specified by:
getStylein interfaceThemeListener.Value- Returns:
- The resolved style for the theme.
-
getThemePreview
Description copied from interface:ThemeListenerGet the theme preview associated with this listener.- Specified by:
getThemePreviewin interfaceThemeListener<T extends DynamicAppTheme>- Returns:
- The theme preview associated with this listener.
-
importTheme
public void importTheme(int themeAction) Description copied from interface:ThemeListener.ImportThis method will be called on importing the theme.- Specified by:
importThemein interfaceThemeListener.Import<T extends DynamicAppTheme>- Parameters:
themeAction- The theme action to be used.
-
importTheme
Description copied from interface:ThemeListener.ImportThis method will be called on importing the theme.- Specified by:
importThemein interfaceThemeListener.Import<T extends DynamicAppTheme>- Parameters:
theme- The theme string to be imported.
-
importTheme
Description copied from interface:ThemeListener.ImportThis method will be called on importing the theme.- Specified by:
importThemein 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.