diff --git a/packages/SystemUI/res-keyguard/drawable/qs_invert_colors_icon_off.xml b/packages/SystemUI/res-keyguard/drawable/qs_invert_colors_icon_off.xml new file mode 100644 index 0000000000000..a34712386d525 --- /dev/null +++ b/packages/SystemUI/res-keyguard/drawable/qs_invert_colors_icon_off.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res-keyguard/drawable/qs_invert_colors_icon_on.xml b/packages/SystemUI/res-keyguard/drawable/qs_invert_colors_icon_on.xml new file mode 100644 index 0000000000000..c5609d8e465b5 --- /dev/null +++ b/packages/SystemUI/res-keyguard/drawable/qs_invert_colors_icon_on.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java index c2a82a76d3e84..a31500c6bb180 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java @@ -49,7 +49,6 @@ import javax.inject.Inject; /** Quick settings tile: Invert colors **/ public class ColorInversionTile extends QSTileImpl { - private final Icon mIcon = ResourceIcon.get(drawable.ic_invert_colors); private final SettingObserver mSetting; @Inject @@ -123,7 +122,9 @@ public class ColorInversionTile extends QSTileImpl { state.value = enabled; state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; state.label = mContext.getString(R.string.quick_settings_inversion_label); - state.icon = mIcon; + state.icon = ResourceIcon.get(state.value + ? drawable.qs_invert_colors_icon_on + : drawable.qs_invert_colors_icon_off); state.expandedAccessibilityClassName = Switch.class.getName(); state.contentDescription = state.label; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java index bf682a8d4e0a3..3fd25019e2a57 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ColorInversionTileTest.java @@ -33,12 +33,15 @@ import androidx.test.filters.SmallTest; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.UiEventLogger; +import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.plugins.ActivityStarter; +import com.android.systemui.plugins.qs.QSTile; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.qs.QSTileHost; import com.android.systemui.qs.logging.QSLogger; +import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.settings.UserTracker; import com.android.systemui.util.settings.FakeSettings; import com.android.systemui.util.settings.SecureSettings; @@ -54,6 +57,8 @@ import org.mockito.MockitoAnnotations; @TestableLooper.RunWithLooper(setAsMainLooper = true) @SmallTest public class ColorInversionTileTest extends SysuiTestCase { + private static final Integer COLOR_INVERSION_DISABLED = 0; + private static final Integer COLOR_INVERSION_ENABLED = 1; @Mock private QSTileHost mHost; @@ -113,4 +118,24 @@ public class ColorInversionTileTest extends SysuiTestCase { assertThat(IntentCaptor.getValue().getAction()).isEqualTo( Settings.ACTION_COLOR_INVERSION_SETTINGS); } + + @Test + public void testIcon_whenColorInversionDisabled_isOffState() { + QSTile.BooleanState state = new QSTile.BooleanState(); + + mTile.handleUpdateState(state, COLOR_INVERSION_DISABLED); + + assertThat(state.icon) + .isEqualTo(QSTileImpl.ResourceIcon.get(R.drawable.qs_invert_colors_icon_off)); + } + + @Test + public void testIcon_whenColorInversionEnabled_isOnState() { + QSTile.BooleanState state = new QSTile.BooleanState(); + + mTile.handleUpdateState(state, COLOR_INVERSION_ENABLED); + + assertThat(state.icon) + .isEqualTo(QSTileImpl.ResourceIcon.get(R.drawable.qs_invert_colors_icon_on)); + } }