Add optimize and postpone transactions.

Bug 29631389
Bug 30502032
Bug 20068723

When multiple operations are executed at once, they sometimes
cancel each other. For example, if the following transactions
are queued:

Transaction 1: add A
Transaction 2: replace with B

This can be trimmed down to add B.

This CL optimizes fragments in both add and pop directions.

Developers can choose not to allow optimization by
using FragmentTransaction#setAllowOptimization

Fragments in a transaction can now indicate when they are ready
and the transaction should complete. Postponed transactions will
have new views in the fragments created and added to the hierarchy
INVISIBLE. When all postponed fragments are ready, the transitions
and animations will start. INVISIBLE views will be made VISIBLE
and removed views will be taken out of the View hierarchy

Test: gradlew connectedCheck in fragment/
Test: manual tests also, just to make sure

Change-Id: I3fdab8e75cb33a02e9e636ff6f43a6f95a564d21
31 files changed