Fix LS Smartspace Text Color
The LS Smartspace was applying the wrong text color because the views were out of bounds due to incorrect calculations with the actual on-screen coordinates. This fix now restricts the view to be within the device width and height. This fix also addresses an issue where the region samplers would not persist on the lockscreen smartspace because they were only being created once and immediately removed when the view was detached from window but never recreated. Now, the region samplers are recreated when the view is re-attached so that text protection on the LS smartspace will persist. Flag: region_sampling Fixes: 283620770 Test: manual, atest RegionSamplerTest Change-Id: Id6bb46c35dcb9e37c9825ba9836a7d5152384844
This commit is contained in:
@@ -202,8 +202,6 @@ constructor(
|
||||
|
||||
fun calculateScreenLocation(sampledView: View): RectF? {
|
||||
|
||||
if (!sampledView.isLaidOut) return null
|
||||
|
||||
val screenLocation = tmpScreenLocation
|
||||
/**
|
||||
* The method getLocationOnScreen is used to obtain the view coordinates relative to its
|
||||
@@ -219,6 +217,10 @@ constructor(
|
||||
samplingBounds.right = left + sampledView.width
|
||||
samplingBounds.bottom = top + sampledView.height
|
||||
|
||||
// ensure never go out of bounds
|
||||
if (samplingBounds.right > displaySize.x) samplingBounds.right = displaySize.x
|
||||
if (samplingBounds.bottom > displaySize.y) samplingBounds.bottom = displaySize.y
|
||||
|
||||
return RectF(samplingBounds)
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,19 @@ constructor(
|
||||
|
||||
updateTextColorFromWallpaper()
|
||||
statusBarStateListener.onDozeAmountChanged(0f, statusBarStateController.dozeAmount)
|
||||
|
||||
if (regionSamplingEnabled && (!regionSamplers.containsKey(v))) {
|
||||
var regionSampler = RegionSampler(
|
||||
v as View,
|
||||
uiExecutor,
|
||||
bgExecutor,
|
||||
regionSamplingEnabled,
|
||||
isLockscreen = true,
|
||||
) { updateTextColorFromRegionSampler() }
|
||||
initializeTextColors(regionSampler)
|
||||
regionSamplers[v] = regionSampler
|
||||
regionSampler.startRegionSampler()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(v: View) {
|
||||
@@ -170,23 +183,6 @@ constructor(
|
||||
|
||||
val filteredTargets = targets.filter(::filterSmartspaceTarget)
|
||||
plugin?.onTargetsAvailable(filteredTargets)
|
||||
if (!isRegionSamplersCreated) {
|
||||
for (v in smartspaceViews) {
|
||||
if (regionSamplingEnabled) {
|
||||
var regionSampler = RegionSampler(
|
||||
v as View,
|
||||
uiExecutor,
|
||||
bgExecutor,
|
||||
regionSamplingEnabled,
|
||||
isLockscreen = true,
|
||||
) { updateTextColorFromRegionSampler() }
|
||||
initializeTextColors(regionSampler)
|
||||
regionSamplers[v] = regionSampler
|
||||
regionSampler.startRegionSampler()
|
||||
}
|
||||
}
|
||||
isRegionSamplersCreated = true
|
||||
}
|
||||
}
|
||||
|
||||
private val userTrackerCallback = object : UserTracker.Callback {
|
||||
|
||||
Reference in New Issue
Block a user