Add smartspace complication even when targets empty.
This CL changes the logic to add smartspace complication even when smartspace targets are empty. The default smartspace card (with only date) should still be displayed, so to be consistent with the lockscreen and laucher. Bug: 243105222 Fix: 243105222 Test: atest SmartSpaceComplicationTest Test: wipe device, enable art gallery screensaver, see the default smartspace card shown with only date info Change-Id: I46af1c5ec017e4eb78ef9cd7e96e887fcb5597bb
This commit is contained in:
@@ -70,11 +70,7 @@ public class SmartSpaceComplication implements Complication {
|
||||
new BcSmartspaceDataPlugin.SmartspaceTargetListener() {
|
||||
@Override
|
||||
public void onSmartspaceTargetsUpdated(List<? extends Parcelable> targets) {
|
||||
if (!targets.isEmpty()) {
|
||||
mDreamOverlayStateController.addComplication(mComplication);
|
||||
} else {
|
||||
mDreamOverlayStateController.removeComplication(mComplication);
|
||||
}
|
||||
mDreamOverlayStateController.addComplication(mComplication);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@@ -60,9 +60,6 @@ public class SmartSpaceComplicationTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private SmartSpaceComplication mComplication;
|
||||
|
||||
@Mock
|
||||
private ComplicationViewModel mComplicationViewModel;
|
||||
|
||||
@Mock
|
||||
private View mBcSmartspaceView;
|
||||
|
||||
@@ -125,12 +122,12 @@ public class SmartSpaceComplicationTest extends SysuiTestCase {
|
||||
|
||||
// Test
|
||||
final SmartspaceTarget target = Mockito.mock(SmartspaceTarget.class);
|
||||
listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList(target));
|
||||
listenerCaptor.getValue().onSmartspaceTargetsUpdated(Collections.singletonList(target));
|
||||
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverlayActive_targetsEmpty_removesComplication() {
|
||||
public void testOverlayActive_targetsEmpty_addsComplication() {
|
||||
final SmartSpaceComplication.Registrant registrant = getRegistrant();
|
||||
registrant.start();
|
||||
|
||||
@@ -145,13 +142,9 @@ public class SmartSpaceComplicationTest extends SysuiTestCase {
|
||||
ArgumentCaptor.forClass(BcSmartspaceDataPlugin.SmartspaceTargetListener.class);
|
||||
verify(mSmartspaceController).addListener(listenerCaptor.capture());
|
||||
|
||||
final SmartspaceTarget target = Mockito.mock(SmartspaceTarget.class);
|
||||
listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList(target));
|
||||
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
||||
|
||||
// Test
|
||||
listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList());
|
||||
verify(mDreamOverlayStateController).removeComplication(eq(mComplication));
|
||||
listenerCaptor.getValue().onSmartspaceTargetsUpdated(Collections.emptyList());
|
||||
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,8 +163,7 @@ public class SmartSpaceComplicationTest extends SysuiTestCase {
|
||||
ArgumentCaptor.forClass(BcSmartspaceDataPlugin.SmartspaceTargetListener.class);
|
||||
verify(mSmartspaceController).addListener(listenerCaptor.capture());
|
||||
|
||||
final SmartspaceTarget target = Mockito.mock(SmartspaceTarget.class);
|
||||
listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList(target));
|
||||
listenerCaptor.getValue().onSmartspaceTargetsUpdated(Collections.emptyList());
|
||||
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
||||
|
||||
// Test
|
||||
|
||||
Reference in New Issue
Block a user