Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50605427 authored by Rasheed Lewis's avatar Rasheed Lewis
Browse files

Replaced Quick Settings Auto-Rotate Icons to Use Animations

Test: Unit tested and manually tested
Bug: 228565281
Change-Id: Ib28bb2612af434e929404572be092efd359aa4fc
parent 1097ed3c
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import javax.inject.Inject;
/** Quick settings tile: Rotation **/
public class RotationLockTile extends QSTileImpl<BooleanState> implements
        BatteryController.BatteryStateChangeCallback {
    private static final String EMPTY_SECONDARY_STRING = "";

    private final Icon mIcon = ResourceIcon.get(com.android.internal.R.drawable.ic_qs_auto_rotate);
    private final RotationLockController mController;
@@ -144,13 +145,15 @@ public class RotationLockTile extends QSTileImpl<BooleanState> implements
                        && mController.isCameraRotationEnabled();
        state.value = !rotationLocked;
        state.label = mContext.getString(R.string.quick_settings_rotation_unlocked_label);
        state.icon = mIcon;
        state.icon = ResourceIcon.get(R.drawable.qs_auto_rotate_icon_off);
        state.contentDescription = getAccessibilityString(rotationLocked);
        if (!rotationLocked && cameraRotation) {
            state.secondaryLabel = mContext.getResources().getString(
                    R.string.rotation_lock_camera_rotation_on);
        if (!rotationLocked) {
            state.secondaryLabel = cameraRotation ? mContext.getResources().getString(
                    R.string.rotation_lock_camera_rotation_on)
                    : EMPTY_SECONDARY_STRING;
            state.icon = ResourceIcon.get(R.drawable.qs_auto_rotate_icon_on);
        } else {
            state.secondaryLabel = "";
            state.secondaryLabel = EMPTY_SECONDARY_STRING;
        }
        state.stateDescription = state.secondaryLabel;

+22 −0
Original line number Diff line number Diff line
@@ -36,9 +36,11 @@ 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.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.DeviceStateRotationLockSettingController;
import com.android.systemui.statusbar.policy.RotationLockController;
@@ -194,6 +196,26 @@ public class RotationLockTileTest extends SysuiTestCase {
        assertEquals("", mLockTile.getState().secondaryLabel.toString());
    }

    @Test
    public void testIcon_whenDisabled_isOffState() {
        QSTile.BooleanState state = new QSTile.BooleanState();
        disableAutoRotation();

        mLockTile.handleUpdateState(state, /* arg= */ null);

        assertEquals(state.icon, QSTileImpl.ResourceIcon.get(R.drawable.qs_auto_rotate_icon_off));
    }

    @Test
    public void testIcon_whenEnabled_isOnState() {
        QSTile.BooleanState state = new QSTile.BooleanState();
        enableAutoRotation();

        mLockTile.handleUpdateState(state, /* arg= */ null);

        assertEquals(state.icon, QSTileImpl.ResourceIcon.get(R.drawable.qs_auto_rotate_icon_on));
    }

    private void enableAutoRotation() {
        when(mRotationPolicyWrapper.isRotationLocked()).thenReturn(false);
    }