Class DynamicSystemActivity

All Implemented Interfaces:
ComponentCallbacks, ComponentCallbacks2, SharedPreferences.OnSharedPreferenceChangeListener, KeyEvent.Callback, LayoutInflater.Factory, LayoutInflater.Factory2, View.OnCreateContextMenuListener, Window.Callback, ContextAware, FullyDrawnReporterOwner, OnBackPressedDispatcherOwner, ActivityResultCaller, ActivityResultRegistryOwner, ActionBarDrawerToggle.DelegateProvider, AppCompatCallback, ActivityCompat.OnRequestPermissionsResultCallback, ActivityCompat.RequestPermissionsRequestCodeValidator, OnMultiWindowModeChangedProvider, OnNewIntentProvider, OnPictureInPictureModeChangedProvider, TaskStackBuilder.SupportParentable, OnConfigurationChangedProvider, OnTrimMemoryProvider, KeyEventDispatcher.Component, MenuHost, HasDefaultViewModelProviderFactory, LifecycleOwner, ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner, DynamicLocale, DynamicListener, DynamicTransitionListener, DynamicProductFlavor
Direct Known Subclasses:
DynamicSplashActivity, DynamicStateActivity, DynamicTutorialActivity

An AppCompatActivity to perform all the system UI related tasks like setting the status and navigation bar colors, theme, etc. It heavily depends on the DynamicTheme that can be customised by implementing the corresponding methods.

Extend this activity and implement the various methods according to the requirements.

  • Field Details

    • ADS_STATE_DYNAMIC_THEME

      protected static final String ADS_STATE_DYNAMIC_THEME
      Dynamic theme key to maintain its state.
      See Also:
    • ADS_STATE_BACKGROUND_COLOR

      protected static final String ADS_STATE_BACKGROUND_COLOR
      Background color key to maintain its state.
      See Also:
    • ADS_STATE_STATUS_BAR_COLOR

      protected static final String ADS_STATE_STATUS_BAR_COLOR
      Status bar color key to maintain its state.
      See Also:
    • ADS_STATE_NAVIGATION_BAR_COLOR

      protected static final String ADS_STATE_NAVIGATION_BAR_COLOR
      Navigation bar color key to maintain its state.
      See Also:
    • ADS_STATE_SHARED_ELEMENT_MAP

      protected static final String ADS_STATE_SHARED_ELEMENT_MAP
      Shared element map key to maintain its state.
      See Also:
    • ADS_STATE_TRANSITION_RESULT_CODE

      protected static final String ADS_STATE_TRANSITION_RESULT_CODE
      Transition result code key to maintain its state.
      See Also:
    • ADS_STATE_TRANSITION_POSITION

      protected static final String ADS_STATE_TRANSITION_POSITION
      Transition position key to maintain its state.
      See Also:
    • ADS_STATE_PAUSED

      protected static final String ADS_STATE_PAUSED
      Paused state key to maintain its state.
      See Also:
    • ADS_DEFAULT_SYSTEM_UI_COLOR

      @ColorInt protected static final int ADS_DEFAULT_SYSTEM_UI_COLOR
      Default tint color for the system UI elements like snackbars, etc.
    • ADS_DEFAULT_SYSTEM_BG_COLOR

      @ColorInt protected static final int ADS_DEFAULT_SYSTEM_BG_COLOR
      Default background color for the system UI elements like status and navigation bar.
    • ADS_DEFAULT_SYSTEM_OVERLAY_COLOR

      @ColorInt protected static final int ADS_DEFAULT_SYSTEM_OVERLAY_COLOR
      Default overlay color for the system UI elements like status and navigation bar.
    • mDynamicDelegate

      protected AppCompatDelegate mDynamicDelegate
      App compat delegate used by this activity.
    • mContext

      protected Context mContext
      Dynamic context used by this activity.
    • mCurrentLocale

      protected Locale mCurrentLocale
      Current locale used by this activity.
    • mBackgroundColor

      @ColorInt protected int mBackgroundColor
      Background color used by the activity window.
    • mStatusBarColor

      @ColorInt protected int mStatusBarColor
      Current status bar color.
    • mAppliedNavigationBarColor

      @ColorInt protected int mAppliedNavigationBarColor
      Applied navigation bar color.
    • mDynamicRunnable

      protected final Runnable mDynamicRunnable
      Runnable to change the dynamic theme on resume.
    • mFinishRunnable

      protected final Runnable mFinishRunnable
      Runnable to finish the activity.
  • Constructor Details

    • DynamicSystemActivity

      public DynamicSystemActivity()
  • Method Details

    • getDelegate

      @NonNull public AppCompatDelegate getDelegate()
      Fix for app compat 1.2.0. Use custom delegate to fix activity configurations (locale, font scale, etc.) when using along with the application configuration.
      Overrides:
      getDelegate in class AppCompatActivity
    • createConfigurationContext

      public Context createConfigurationContext(Configuration overrideConfiguration)
      Overrides:
      createConfigurationContext in class ContextWrapper
    • onCreate

      protected void onCreate(@Nullable Bundle savedInstanceState)
      Overrides:
      onCreate in class FragmentActivity
    • onPostCreate

      protected void onPostCreate(@Nullable Bundle savedInstanceState)
      Overrides:
      onPostCreate in class AppCompatActivity
    • onNewIntent

      protected void onNewIntent(Intent intent)
      Overrides:
      onNewIntent in class ComponentActivity
    • onConfigureOnBackPressedDispatcher

      protected void onConfigureOnBackPressedDispatcher()
      This method will be called to configure on back pressed callback to support API 33 and above.
    • onNewIntent

      @CallSuper protected void onNewIntent(@Nullable Intent intent, boolean newIntent)
      Setup content according to the intent.
      Parameters:
      intent - The received intent.
      newIntent - true if updating from the new intent.
    • onUpdateIntent

      protected void onUpdateIntent(@Nullable Intent intent, boolean newIntent)
      Update content according to the intent.
      Parameters:
      intent - The received intent.
      newIntent - true if updating from the new intent.
    • isThemeActivity

      protected boolean isThemeActivity()
      Returns whether this activity can handle theme intents.
      Returns:
      true if this activity can handle theme intents.
      See Also:
    • checkForThemeIntent

      public void checkForThemeIntent(@Nullable Intent intent)
      Checks for the valid dynamic theme intent.
      Parameters:
      intent - The intent to be checked.
      See Also:
    • onThemeIntent

      protected void onThemeIntent(@Nullable String data, @Nullable String name)
      This method will be called on successfully verifying the dynamic theme intent.
      Parameters:
      data - The theme data retrieved from the intent.
      name - The theme or file name retrieved from the intent.
      See Also:
    • onSetSharedElementTransition

      protected void onSetSharedElementTransition()
      Setup the shared element transition fot this activity.
    • onManageSharedElementTransition

      protected void onManageSharedElementTransition()
      Setup the shared element transition callbacks to manage it's position on configuration change.
    • onApplyTransitions

      public void onApplyTransitions(boolean exit)
      Description copied from interface: DynamicTransitionListener
      This method will be called on applying transitions.

      It is recommended to do any shared element adjustments here like postponing the transition.

      Specified by:
      onApplyTransitions in interface DynamicTransitionListener
      Parameters:
      exit - true if the activity is exiting.
    • getDynamicEnterTransition

      @Nullable public Object getDynamicEnterTransition()
      Description copied from interface: DynamicTransitionListener
      Returns the enter transition used by his listener.
      Specified by:
      getDynamicEnterTransition in interface DynamicTransitionListener
      Returns:
      The enter transition used by his listener.
      See Also:
    • getDynamicReturnTransition

      @Nullable public Object getDynamicReturnTransition()
      Description copied from interface: DynamicTransitionListener
      Returns the return transition used by his listener.
      Specified by:
      getDynamicReturnTransition in interface DynamicTransitionListener
      Returns:
      The return transition transition used by his listener.
      See Also:
    • getDynamicExitTransition

      @Nullable public Object getDynamicExitTransition()
      Description copied from interface: DynamicTransitionListener
      Returns the exit transition used by his listener.
      Specified by:
      getDynamicExitTransition in interface DynamicTransitionListener
      Returns:
      The exit transition used by his listener.
      See Also:
    • getDynamicReenterTransition

      @Nullable public Object getDynamicReenterTransition()
      Description copied from interface: DynamicTransitionListener
      Returns the reenter transition used by his listener.
      Specified by:
      getDynamicReenterTransition in interface DynamicTransitionListener
      Returns:
      The reenter transition used by his listener.
      See Also:
    • onAdjustEnterReturnTransition

      @Nullable public Object onAdjustEnterReturnTransition(@Nullable Object transition, boolean enter)
      Description copied from interface: DynamicTransitionListener
      This method will be called to optionally to adjust the enter and return transitions before applying.
      Specified by:
      onAdjustEnterReturnTransition in interface DynamicTransitionListener
      Parameters:
      transition - The transition to be adjusted.
      enter - true if enter transition, otherwise return transition.
      Returns:
      The adjusted enter or return transition before applying.
      See Also:
    • onAdjustExitReenterTransition

      @Nullable public Object onAdjustExitReenterTransition(@Nullable Object transition, boolean exit)
      Description copied from interface: DynamicTransitionListener
      This method will be called to optionally to adjust the exit and reenter transitions before applying.
      Specified by:
      onAdjustExitReenterTransition in interface DynamicTransitionListener
      Parameters:
      transition - The transition to be adjusted.
      exit - true if exit transition, otherwise reenter transition.
      Returns:
      The adjusted exit or reenter transition before applying.
      See Also:
    • getPostponeTransitionView

      @Nullable public View getPostponeTransitionView()
      Description copied from interface: DynamicTransitionListener
      This method will be called to postpone the transition until the returned view is laid.

      It will be called only on API 21 and above.

      Specified by:
      getPostponeTransitionView in interface DynamicTransitionListener
      Returns:
      The view to postpone the transition.
    • onFindView

      @Nullable public View onFindView(int resultCode, int position, @NonNull String transition, @IdRes int viewId)
      Description copied from interface: DynamicTransitionListener
      This method will be called to find the view according to the transition name or resource id.

      It will be called only on API 21 and above.

      Specified by:
      onFindView in interface DynamicTransitionListener
      Parameters:
      resultCode - The transition result code.
      position - The position of the shared element.
      transition - The transition name of the view.
      viewId - The id resource to find the view by id.
      Returns:
      The view according to the view id.
    • resetSharedElementTransition

      protected void resetSharedElementTransition()
      Resets the shared element transition.
    • commitFragmentTransaction

      public void commitFragmentTransaction(@NonNull FragmentTransaction fragmentTransaction)
      Commit the fragment transaction.
      Parameters:
      fragmentTransaction - The fragment transaction to be committed.
    • onSaveInstanceState

      public void onSaveInstanceState(@NonNull Bundle outState)
      Overrides:
      onSaveInstanceState in class ComponentActivity
    • getSupportedLocales

      @Nullable public String[] getSupportedLocales()
      Specified by:
      getSupportedLocales in interface DynamicLocale
    • getDefaultLocale

      @NonNull public Locale getDefaultLocale(@NonNull Context context)
      Specified by:
      getDefaultLocale in interface DynamicLocale
    • getLocale

      @Nullable public Locale getLocale()
      Specified by:
      getLocale in interface DynamicLocale
    • setLocale

      @NonNull public Context setLocale(@NonNull Context context)
      Specified by:
      setLocale in interface DynamicLocale
    • getFontScale

      public float getFontScale()
      Specified by:
      getFontScale in interface DynamicLocale
    • onCustomiseTheme

      protected void onCustomiseTheme()
      This method will be called just before the onCreate(Bundle) after applying the theme.

      Override this method to customise the theme further.

    • onAdjustElevation

      protected void onAdjustElevation()
      This method will be called to adjust elevation of the components like app bar, bottom app bar, etc.
    • getDynamicLayoutInflater

      @Nullable protected LayoutInflater.Factory2 getDynamicLayoutInflater()
      Returns a layout inflater factory for this activity.

      It will be used to replace the app compat widgets with their dynamic counterparts to provide the support for dynamic theme.

      Override this method to provide a custom layout inflater.

      Returns:
      The layout inflater factory for this activity.
    • getContentView

      @Nullable public abstract View getContentView()
      Returns the parent content view used by this activity.
      Returns:
      The parent content view used by this activity.
    • getCurrentLocale

      @NonNull public Locale getCurrentLocale()
      Get the current locale used by this activity.
      Returns:
      The current locale used by this activity.
    • getSavedInstanceState

      @Nullable public Bundle getSavedInstanceState()
      Get the current saved instance state for this activity.
      Returns:
      The current saved instance state for this activity.
    • getDynamicIntentTheme

      @Nullable public AppTheme<?> getDynamicIntentTheme()
      Returns the dynamic app theme received from the intent.
      Returns:
      The dynamic app theme received from the intent.
    • getTransitionResultCode

      public int getTransitionResultCode()
      Returns the transition result code for this activity.
      Returns:
      The transition result code for this activity.
    • setTransitionResultCode

      public void setTransitionResultCode(int transitionResultCode)
      Sets the transition result code for this activity.
      Parameters:
      transitionResultCode - The transition result code to be set.
    • getTransitionPosition

      public int getTransitionPosition()
      Returns the transition position of the shared element.
      Returns:
      The transition position of the shared element.
    • setTransitionPosition

      public void setTransitionPosition(int transitionPosition)
      Sets the transition position of the shared element.
      Parameters:
      transitionPosition - The transition position to be set.
    • getSharedElementTransition

      @Nullable public Transition getSharedElementTransition()
      Returns the shared element transition.
      Returns:
      The shared element transition.
    • setSharedElementTransition

      public void setSharedElementTransition(@Nullable Transition sharedElementTransition)
      Sets the shared element transition.
      Parameters:
      sharedElementTransition - The shared element transition to be set.
    • getSharedElementCallback

      @Nullable public SharedElementCallback getSharedElementCallback()
      Returns the callback for the shared element transition.
      Returns:
      The callback for the shared element transition.
    • setSharedElementCallback

      public void setSharedElementCallback(@Nullable SharedElementCallback sharedElementCallback)
      Sets the callback for the shared element transition.
      Parameters:
      sharedElementCallback - The callback for the shared element transition.
    • getDynamicTransitionListener

      @Nullable public DynamicTransitionListener getDynamicTransitionListener()
      Returns the dynamic transition listener used by this activity.
      Returns:
      The dynamic transition listener used by this activity.
    • setDynamicTransitionListener

      public void setDynamicTransitionListener(@Nullable DynamicTransitionListener dynamicTransitionListener)
      Sets the dynamic transition listener for this activity.
      Parameters:
      dynamicTransitionListener - The dynamic transition listener to be set.
    • isLaunchedFromHistory

      public boolean isLaunchedFromHistory()
      Checks whether this activity is launched from the history.
      Returns:
      true if this activity is launched from the history.
    • isNavigationBarTheme

      public boolean isNavigationBarTheme()
      Returns whether the navigation bar theme is applied for this activity.
      Returns:
      true if navigation bar theme is applied.
    • setNavigationBarThemeInLandscape

      protected boolean setNavigationBarThemeInLandscape()
      Sets whether the navigation bar theme should be applied for this activity in landscape mode.

      It will be applied only on the API 21 and above.

      By default it will use the Theme.ColorType.PRIMARY_DARK color, use setNavigationBarColor(int) to set a custom color.

      Returns:
      true to apply navigation bar theme for this activity in the landscape mode.
    • onAppThemeChange

      protected void onAppThemeChange()
      This method will be called after the theme has been changed.

      Override this method to perform operations after the theme has been changed like re-initialize the DynamicTheme with new colors, etc.

    • getBackgroundColor

      @ColorInt public int getBackgroundColor()
      Returns the default background color for this activity.
      Returns:
      The default background color for this activity.
    • setWindowBackground

      public void setWindowBackground(@ColorInt int color)
      Sets the window background color.
      Parameters:
      color - The window background color to be set.
      See Also:
    • setRootBackground

      public void setRootBackground(@ColorInt int color)
      Sets the root background color.
      Parameters:
      color - The root background color to be set.
      See Also:
    • setWindowStatusBarColor

      protected void setWindowStatusBarColor(@ColorInt int color)
      Set the status bar color.

      It will be applied only on the API 21 and above.

      Parameters:
      color - Color to be applied on the status bar.
    • setStatusBarColor

      public void setStatusBarColor(@ColorInt int color)
      Set the status bar color.

      It will be applied only on the API 21 and above.

      Parameters:
      color - The color to be applied.
    • setStatusBarColorRes

      public void setStatusBarColorRes(@ColorRes int colorRes)
      Set the status bar color resource.

      It will be applied only on the API 21 and above.

      Parameters:
      colorRes - The color resource to be applied.
    • setTranslucentStatusBar

      public void setTranslucentStatusBar()
      Set the translucent status bar flag, useful in case of CollapsingToolbarLayout.

      It will be applied only on the API 21 and above.

    • updateStatusBar

      protected void updateStatusBar()
      Update status bar color according to the supplied parameters. It will automatically check for the light or dark color and will change the status bar icons or background accordingly so that the icons will always be visible.
    • isEdgeToEdgeContent

      public boolean isEdgeToEdgeContent()
      Checks whether to enable edge-to-edge content.

      Override this method to provide your own implementation.

      Returns:
      true to enable edge-to-edge content.
    • getEdgeToEdgeView

      @Nullable public View getEdgeToEdgeView()
      Returns the view to apply edge-to-edge window insets.
      Returns:
      The view to apply edge-to-edge window insets.
      See Also:
    • isApplyEdgeToEdgeInsets

      public boolean isApplyEdgeToEdgeInsets()
      Returns whether to apply edge-to-edge window insets.
      Returns:
      true to apply edge-to-edge window insets.
      See Also:
    • getEdgeToEdgeViewBottom

      @Nullable public View getEdgeToEdgeViewBottom()
      Returns the bottom view to apply edge-to-edge window insets.
      Returns:
      The bottom view to apply edge-to-edge window insets.
      See Also:
    • getCoordinatorLayout

      @Nullable public CoordinatorLayout getCoordinatorLayout()
      Returns the coordinator layout used by this activity.
      Returns:
      The coordinator layout used by this activity.
    • isApplyFooterInsets

      public boolean isApplyFooterInsets()
      Returns whether to apply footer window insets.
      Returns:
      true to apply footer window insets.
    • setNavigationBarColor

      public void setNavigationBarColor(@ColorInt int color)
      Set the navigation bar color.

      It will be applied only on the API 21 and above.

      Parameters:
      color - The color to be applied.
    • setNavigationBarColorRes

      public void setNavigationBarColorRes(@ColorRes int colorRes)
      Set the navigation bar color resource.

      It will be applied only on the API 21 and above.

      Parameters:
      colorRes - The color resource to be applied.
    • setTranslucentNavigationBar

      public void setTranslucentNavigationBar()
      Set the translucent navigation bar flag, useful in case of to show the layout behind the navigation bar.

      It will be applied only on the API 21 and above.

    • updateNavigationBar

      protected void updateNavigationBar()
      Update navigation bar color according to the supplied parameters. It will automatically check for the light or dark color and will background accordingly so that the buttons will always be visible.
    • getStatusBarColor

      @ColorInt public int getStatusBarColor()
      Get the current status bar color.
      Returns:
      The current status bar color.
    • getNavigationBarColor

      @ColorInt public int getNavigationBarColor()
      Get the current (original) navigation bar color.

      It may be different from the actually applied color. To get the user visible color, use getAppliedNavigationBarColor().

      Returns:
      The current navigation bar color.
      See Also:
    • getAppliedNavigationBarColor

      @ColorInt public int getAppliedNavigationBarColor()
      Get the applied navigation bar color.
      Returns:
      The applied navigation bar color.
    • startActivity

      public void startActivity(Intent intent)
      Overrides:
      startActivity in class Activity
    • startActivity

      public void startActivity(Intent intent, @Nullable Bundle options)
      Overrides:
      startActivity in class Activity
    • startActivityForResult

      public void startActivityForResult(Intent intent, int requestCode)
      Overrides:
      startActivityForResult in class ComponentActivity
    • startActivityForResult

      public void startActivityForResult(Intent intent, int requestCode, @Nullable Bundle options)
      Overrides:
      startActivityForResult in class ComponentActivity
    • startActivityFromFragment

      public void startActivityFromFragment(@NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options)
      Overrides:
      startActivityFromFragment in class FragmentActivity
    • startMotionActivity

      public void startMotionActivity(Intent intent, @Nullable Bundle options, boolean motion, boolean finish, boolean afterTransition)
      Call startActivity(Intent, Bundle) for this activity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      intent - The intent to be used.
      options - The intent to be set.
      motion - true if motion is enabled.
      finish - true to finish calling activity.
      afterTransition - true to finish the calling activity after transition.
    • startMotionActivity

      public void startMotionActivity(Intent intent, @Nullable Bundle options, boolean finish, boolean afterTransition)
      Call startActivity(Intent, Bundle) for this activity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      intent - The intent to be used.
      options - The intent to be set.
      finish - true to finish calling activity.
      afterTransition - true to finish the calling activity after transition.
      See Also:
    • startMotionActivityForResult

      public void startMotionActivityForResult(Intent intent, int requestCode, @Nullable Bundle options, boolean motion, boolean finish, boolean afterTransition)
      Call startActivityForResult(Intent, int, Bundle) for this activity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
      motion - true if motion is enabled.
      finish - true to finish calling activity.
      afterTransition - true to finish the calling activity after transition.
    • startMotionActivityForResult

      public void startMotionActivityForResult(Intent intent, int requestCode, @Nullable Bundle options, boolean finish, boolean afterTransition)
      Call startActivityForResult(Intent, int, Bundle) for this activity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
      finish - true to finish calling activity.
      afterTransition - true to finish the calling activity after transition.
      See Also:
    • startMotionActivityForResult

      public void startMotionActivityForResult(Intent intent, int requestCode, @Nullable Bundle options)
      Call startActivityForResult(Intent, int, Bundle) for this activity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
    • startMotionActivity

      public void startMotionActivity(Intent intent, @Nullable Bundle options)
      Call startActivity(Intent, Bundle) for this activity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      intent - The intent to be used.
      options - The intent to be set.
    • startMotionActivityFromFragment

      public void startMotionActivityFromFragment(@NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options, boolean motion, boolean finish, boolean afterTransition)
      Called by Fragment.startActivityForResult() to implement its behavior.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      fragment - The calling fragment.
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
      motion - true if motion is enabled.
      finish - true to finish calling activity.
      afterTransition - true to finish the calling activity after transition.
    • startMotionActivityFromFragment

      public void startMotionActivityFromFragment(@NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options, boolean finish, boolean afterTransition)
      Called by Fragment.startActivityForResult() to implement its behavior.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      fragment - The calling fragment.
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
      finish - true to finish calling activity.
      afterTransition - true to finish the calling activity after transition.
      See Also:
    • startMotionActivityFromFragment

      public void startMotionActivityFromFragment(@NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options)
      Called by Fragment.startActivityForResult() to implement its behavior.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      fragment - The calling fragment.
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
    • onStartActivityException

      protected void onStartActivityException(@Nullable Exception exception)
      This method will be called when there is an exception on starting the activity from this activity.
      Parameters:
      exception - The exception occurred.
      See Also:
    • isForceMenuIcons

      public boolean isForceMenuIcons()
      Returns whether to force menu icons for this activity.
      Returns:
      true if force menu icons for this activity.
      See Also:
    • onPrepareOptionsMenu

      public boolean onPrepareOptionsMenu(Menu menu)
      Overrides:
      onPrepareOptionsMenu in class Activity
    • onResume

      public void onResume()
      Overrides:
      onResume in class FragmentActivity
    • onPause

      public void onPause()
      Overrides:
      onPause in class FragmentActivity
    • onDestroy

      public void onDestroy()
      Overrides:
      onDestroy in class AppCompatActivity
    • getProductFlavor

      public String getProductFlavor()
      Specified by:
      getProductFlavor in interface DynamicProductFlavor
    • getContext

      @NonNull public Context getContext()
      Description copied from interface: DynamicListener
      Returns the context used by this listener.
      Specified by:
      getContext in interface DynamicListener
      Returns:
      The context used by this listener.
    • getRequiredThemeVersion

      public int getRequiredThemeVersion()
      Description copied from interface: DynamicListener
      This method will be called to get the intended theme styles version for this listener.
      Specified by:
      getRequiredThemeVersion in interface DynamicListener
      Returns:
      The intended theme styles version for this listener.
    • isNightMode

      public boolean isNightMode(boolean resolve)
      Description copied from interface: DynamicListener
      Checks whether the night mode is enabled for this listener.
      Specified by:
      isNightMode in interface DynamicListener
      Parameters:
      resolve - true to resolve based on the theme data.
      Returns:
      true if the night mode is enabled for this listener.
    • getThemeRes

      @StyleRes public int getThemeRes(@Nullable AppTheme<?> theme)
      Description copied from interface: DynamicListener
      This method will be called to return the theme style resource for this listener.

      Override this method to supply your own customised style.

      Specified by:
      getThemeRes in interface DynamicListener
      Parameters:
      theme - The optional dynamic theme to resolve the style resource.
      Returns:
      The theme style resource for this listener.
      See Also:
    • getThemeRes

      @StyleRes public int getThemeRes()
      Description copied from interface: DynamicListener
      This method will be called to return the theme style resource for this listener.

      Override this method to supply your own customised style.

      Specified by:
      getThemeRes in interface DynamicListener
      Returns:
      The theme style resource for this listener.
      See Also:
    • getDynamicTheme

      @Nullable public AppTheme<?> getDynamicTheme()
      Description copied from interface: DynamicListener
      This method will be called to return the dynamic app theme for this listener.

      Override this method to supply your own customised theme.

      Specified by:
      getDynamicTheme in interface DynamicListener
      Returns:
      The dynamic app theme for this listener.
    • isDynamicColors

      public boolean isDynamicColors()
      Description copied from interface: DynamicListener
      Returns whether the dynamic colors are enabled for this listener.
      Specified by:
      isDynamicColors in interface DynamicListener
      Returns:
      true if the dynamic colors are enabled for this listener.
    • isDynamicColor

      public boolean isDynamicColor()
      Description copied from interface: DynamicListener
      Returns whether to apply the dynamic colors for this listener.
      Specified by:
      isDynamicColor in interface DynamicListener
      Returns:
      true if the dynamic colors should be applied for this listener.
    • isSystemColor

      public boolean isSystemColor()
      Description copied from interface: DynamicListener
      Returns whether the dynamic colors should be extracted from the system for this listener.
      Specified by:
      isSystemColor in interface DynamicListener
      Returns:
      true if the dynamic colors should be extracted from the system for this listener
    • isWallpaperColor

      public boolean isWallpaperColor()
      Description copied from interface: DynamicListener
      Returns whether the dynamic colors should be extracted from the wallpaper for this listener.
      Specified by:
      isWallpaperColor in interface DynamicListener
      Returns:
      true if the dynamic colors should be extracted from the wallpaper for this listener
    • getDefaultColor

      @ColorInt public int getDefaultColor(int colorType)
      Description copied from interface: DynamicListener
      This method will be called to resolve the default color according to it's type.

      It is useful in resolving the color if the default theme also has auto values.

      Specified by:
      getDefaultColor in interface DynamicListener
      Parameters:
      colorType - The color type to be resolved.
      Returns:
      The resolved default color according to the color type.
      See Also:
    • isOnSharedPreferenceChangeListener

      public boolean isOnSharedPreferenceChangeListener()
      Description copied from interface: DynamicListener
      Returns whether to register a shared preferences listener for this listener.
      Specified by:
      isOnSharedPreferenceChangeListener in interface DynamicListener
      Returns:
      true to register a SharedPreferences.OnSharedPreferenceChangeListener to receive preference change callback.
    • onDynamicChanged

      public void onDynamicChanged(boolean context, boolean recreate)
      Description copied from interface: DynamicListener
      This method will be called when the dynamic change event occurs (like theme, locale, etc.).

      Recreate the activity or application here to adapt changes.

      Specified by:
      onDynamicChanged in interface DynamicListener
      Parameters:
      context - true if there is a context change and it must be reinitialized.
      recreate - true if listener must be recreated to adapt the changes.
    • onDynamicConfigurationChanged

      public void onDynamicConfigurationChanged(boolean locale, boolean fontScale, boolean orientation, boolean uiMode, boolean density)
      Description copied from interface: DynamicListener
      This method will be called when the dynamic configuration change event occurs (like locale, font scale, orientation, ui mode, etc.).

      It will provide more control on DynamicListener.onDynamicChanged(boolean, boolean) method call.

      Specified by:
      onDynamicConfigurationChanged in interface DynamicListener
      Parameters:
      locale - true if locale is changed.
      fontScale - true if font scale is changed.
      orientation - true if there is an orientation change.
      uiMode - true if ui mode is changed.
      density - true if configuration density is changed.
      See Also:
    • onDynamicColorsChanged

      public void onDynamicColorsChanged(@Nullable DynamicColors colors, boolean context)
      Description copied from interface: DynamicListener
      This method will be called when the dynamic color change event occurs according to the wallpaper.

      Recreate the activity or application here to adapt changes.

      Specified by:
      onDynamicColorsChanged in interface DynamicListener
      Parameters:
      colors - The new dynamic colors.
      context - true if there is a context change and it must be reinitialized.
    • onAutoThemeChanged

      public void onAutoThemeChanged(boolean context)
      Description copied from interface: DynamicListener
      This method will be called when the auto theme change event occurs according to the time.

      Recreate the activity or application here to adapt changes.

      Specified by:
      onAutoThemeChanged in interface DynamicListener
      Parameters:
      context - true if there is a context change and it must be reinitialized.
    • onPowerSaveModeChanged

      public void onPowerSaveModeChanged(boolean powerSaveMode)
      Description copied from interface: DynamicListener
      This method will be called when the power save mode has been changed.

      It will be called only on API 21 and above.

      Specified by:
      onPowerSaveModeChanged in interface DynamicListener
      Parameters:
      powerSaveMode - true if the device is in power save mode.
    • setNavigationBarTheme

      public boolean setNavigationBarTheme()
      Sets whether the navigation bar theme should be applied for this activity.

      It will be applied only on the API 21 and above.

      By default it will use the Theme.ColorType.PRIMARY_DARK color, use setNavigationBarColor(int) to set a custom color.

      Specified by:
      setNavigationBarTheme in interface DynamicListener
      Returns:
      true to apply navigation bar theme for this activity.
    • onNavigationBarThemeChanged

      public void onNavigationBarThemeChanged()
      Description copied from interface: DynamicListener
      This method will be called when the navigation bar theme has been changed.
      Specified by:
      onNavigationBarThemeChanged in interface DynamicListener
    • onSharedPreferenceChanged

      public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, @Nullable String key)
      Specified by:
      onSharedPreferenceChanged in interface SharedPreferences.OnSharedPreferenceChangeListener
    • updateTaskDescription

      protected void updateTaskDescription(@ColorInt int color)
      Update the task description on API 21 and above to match it with the theme color.
      Parameters:
      color - The color to be set.
    • onBackPressed

      public void onBackPressed()
      Overrides:
      onBackPressed in class ComponentActivity
    • finish

      public void finish()
      Overrides:
      finish in class Activity
    • supportStartPostponedEnterTransition

      public void supportStartPostponedEnterTransition()
      Overrides:
      supportStartPostponedEnterTransition in class FragmentActivity
    • supportFinishAfterTransition

      public void supportFinishAfterTransition()
      Overrides:
      supportFinishAfterTransition in class FragmentActivity
    • onSetFallbackActivityOptions

      protected void onSetFallbackActivityOptions()
      This method will be called on setting the fallback activity options on unsupported API levels like overriding a pending transition on API 15 and below.
    • isSupportFinishAfterTransition

      public boolean isSupportFinishAfterTransition()
      Checks whether this activity should be finished after the transition.
      Returns:
      Returns true if this activity should be finished after the transition.
      See Also:
    • isPaused

      public boolean isPaused()
      Checks whether the activity was paused before.
      Returns:
      true if the activity was paused before.
    • finishActivity

      public void finishActivity()
      Finish the activity properly after checking the shared element transition.