diff --git a/res/values/integers.xml b/res/values/integers.xml new file mode 100644 index 00000000..e4601cbe --- /dev/null +++ b/res/values/integers.xml @@ -0,0 +1,10 @@ + + + + 250 + 0 + diff --git a/src/com/github/iusmac/sevensim/ui/components/CollapsingToolbarBaseActivity.java b/src/com/github/iusmac/sevensim/ui/components/CollapsingToolbarBaseActivity.java index ae1d68e7..62c1bbe3 100644 --- a/src/com/github/iusmac/sevensim/ui/components/CollapsingToolbarBaseActivity.java +++ b/src/com/github/iusmac/sevensim/ui/components/CollapsingToolbarBaseActivity.java @@ -34,8 +34,6 @@ * the box. */ public abstract class CollapsingToolbarBaseActivity extends FragmentActivity { - private static final int SCRIM_ANIMATION_DURATION = 250; - private CollapsingToolbarDelegate mToolbardelegate; private ToolbarDecorator mToolbarDecorator; private ViewModel mViewModel; @@ -58,9 +56,10 @@ protected void onCreate(final @Nullable Bundle savedInstanceState) { final ToolbarDecorator toolbarDecorator = getToolbarDecorator(); if (toolbarDecorator.isCollapsingToolbarSupported()) { - // Override the default AOSP's value of 50ms, which is too short and makes the scrim - // flicker on <60Hz displays - getCollapsingToolbarLayout().setScrimAnimationDuration(SCRIM_ANIMATION_DURATION); + final int scrimAnimationDuration = getResources().getInteger(isExpressiveTheme ? + R.integer.collapsingtoolbar_scrim_anim_duration_expressive + : R.integer.collapsingtoolbar_scrim_anim_duration); + getCollapsingToolbarLayout().setScrimAnimationDuration(scrimAnimationDuration); // Enforce fade in/out and translate collapse effect for the title so that it's // consistent with the subtitle that doesn't support scaling, which may be selected if // using non-AOSP sources @@ -84,6 +83,9 @@ protected void onCreate(final @Nullable Bundle savedInstanceState) { // Hide the action button by default when expressive theme is enabled. setActionButtonEnabled(false); } + // Our use case requires the CollapsingToolbar to be permanently lifted above the + // scrollable content (safe to disable; less animations, better performance) + getAppBarLayout().setLiftable(false); } else { // For better UX (e.g. l10n), apply the marquee effect on the title for non-collapsing // Toolbar