Offset bounds by card top padding to align lockscreen/launcher smartspaces.

This fixes the issue where the smartspace jumps
around when an alarm is set, and the lockscreen
smartspace has three text lines while launcher's
has two.

Bug: 232413750
Test: unlock with/without alarm set
Change-Id: Iaca7d62779f9f45b94833272d853bbfc2cbc42ae
This commit is contained in:
Josh Tsuji
2022-05-06 14:05:01 -04:00
parent c0573c9851
commit 209f3c92b8
4 changed files with 24 additions and 0 deletions

View File

@@ -134,6 +134,12 @@ public interface BcSmartspaceDataPlugin extends Plugin {
* Get the index of the currently selected page.
*/
int getSelectedPage();
/**
* Return the top padding value from the currently visible card, or 0 if there is no current
* card.
*/
int getCurrentCardTopPadding();
}
/** Interface for launching Intents, which can differ on the lockscreen */

View File

@@ -404,7 +404,19 @@ class KeyguardUnlockAnimationController @Inject constructor(
if (willUnlockWithSmartspaceTransition) {
lockscreenSmartspaceBounds = Rect().apply {
lockscreenSmartspace!!.getBoundsOnScreen(this)
// The smartspace container on the lockscreen has left and top padding to align it
// with other lockscreen content. This padding is inside the bounds on screen, so
// add it to those bounds so that the padding-less launcher smartspace is properly
// aligned.
offset(lockscreenSmartspace!!.paddingLeft, lockscreenSmartspace!!.paddingTop)
// Also offset by the current card's top padding, if it has any. This allows us to
// align the tops of the lockscreen/launcher smartspace cards. Some cards, such as
// the three-line date/weather/alarm card, only have three lines on lockscreen but
// two on launcher.
offset(0, (lockscreenSmartspace
as? BcSmartspaceDataPlugin.SmartspaceView)?.currentCardTopPadding ?: 0)
}
}

View File

@@ -151,6 +151,8 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {
override fun setMediaTarget(target: SmartspaceTarget?) {}
override fun getSelectedPage(): Int { return 0; }
override fun getCurrentCardTopPadding(): Int { return 0; }
}
/**

View File

@@ -603,6 +603,10 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
override fun getSelectedPage(): Int {
return -1
}
override fun getCurrentCardTopPadding(): Int {
return 0
}
})
}
}