Skip to content
Commit 32a20b39 authored by Hai Zhang's avatar Hai Zhang
Browse files

Improve SettingsTransitionActivity for standalone usage.

- Allow subclass to override when the transition should be enabled,
because we may not want to enable it on other form factors, e.g. on
wear.

- Retrieve the Toolbar instance by overriding setActionBar() which
should be called by any activity using Toolbar as its action bar. Even
if there's any activity not using Toolbar as action bar, it won't
behave well with our transition anyway.

- Refactored ActivityOptions Bundle creation logic to simplify the
code. I did the refactoring originally for sharing it with a new
SettingsTransitionFragment, but then realized doing it in fragment
would be very tedious and unreliable. Still the refactoring looks a
good simplification to me.

- Don't override onOptionsItemSelected() in SettingsTransitionActivity
because different form factors might be expecting different behaviors
for the home/up indicator on Toolbar, e.g. we might expand/collapse a
drawer or do something else instead of finishing the current activity
on Tablet.

    The original implementation that calls onBackPressed() is also
technically incorrect because pressing up is a different action. The
reason the original implementation did so is probably for enabling
transition upon activity finish, but that should actually be done by
calling finishAfterTransition(), so I've fixed the
CollapsingToolbarBaseActivity to call finishAfterTransition() instead
of finish(). This shouldn't bring any regression to existing users of
SettingsTransitionActivity as well because currently the only user of
it is CollapsingToolbarBaseActivity.

Bug: 177638625
Test: manually on R and S platforms
Change-Id: I3c5955db3753f00604b625bd21bf7e78f237ec15
parent 15bfc8ac
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment