Refactors for readability and adds an API >M check to be compatible with
the LinearLayout fix that also targets API >M.
This revert commit reverts revert commit
9d8a230f
which originally reverted commit
9cefbda1.
Change-Id: I587d733abef0b35a1bb14b6272054322494a7cdd