FileDocCategorySizeDatePackage
RotationLockTile.javaAPI DocAndroid 5.1 API5534Thu Mar 12 22:22:42 GMT 2015com.android.systemui.qs.tiles

RotationLockTile

public class RotationLockTile extends com.android.systemui.qs.QSTile
Quick settings tile: Rotation

Fields Summary
private final AnimationIcon
mPortraitToAuto
private final AnimationIcon
mAutoToPortrait
private final AnimationIcon
mLandscapeToAuto
private final AnimationIcon
mAutoToLandscape
private final com.android.systemui.statusbar.policy.RotationLockController
mController
private final com.android.systemui.statusbar.policy.RotationLockController.RotationLockControllerCallback
mCallback
Constructors Summary
public RotationLockTile(Host host)


       
        super(host);
        mController = host.getRotationLockController();
    
Methods Summary
protected java.lang.StringcomposeChangeAnnouncement()

        return getAccessibilityString(mState.value,
                R.string.accessibility_rotation_lock_on_portrait_changed,
                R.string.accessibility_rotation_lock_on_landscape_changed,
                R.string.accessibility_rotation_lock_off_changed);
    
private java.lang.StringgetAccessibilityString(boolean locked, int idWhenPortrait, int idWhenLandscape, int idWhenOff)
Get the correct accessibility string based on the state

param
locked Whether or not rotation is locked.
param
idWhenPortrait The id which should be used when locked in portrait.
param
idWhenLandscape The id which should be used when locked in landscape.
param
idWhenOff The id which should be used when the rotation lock is off.
return

        int stringID;
        if (locked) {
            final boolean portrait = mContext.getResources().getConfiguration().orientation
                    != Configuration.ORIENTATION_LANDSCAPE;
            stringID = portrait ? idWhenPortrait: idWhenLandscape;
        } else {
            stringID = idWhenOff;
        }
        return mContext.getString(stringID);
    
protected voidhandleClick()

        if (mController == null) return;
        final boolean newState = !mState.value;
        mController.setRotationLocked(newState);
        refreshState(newState ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE);
    
protected voidhandleUpdateState(BooleanState state, java.lang.Object arg)

        if (mController == null) return;
        final boolean rotationLocked = arg != null ? ((UserBoolean) arg).value
                : mController.isRotationLocked();
        final boolean userInitiated = arg != null ? ((UserBoolean) arg).userInitiated : false;
        state.visible = mController.isRotationLockAffordanceVisible();
        state.value = rotationLocked;
        final boolean portrait = mContext.getResources().getConfiguration().orientation
                != Configuration.ORIENTATION_LANDSCAPE;
        final AnimationIcon icon;
        if (rotationLocked) {
            final int label = portrait ? R.string.quick_settings_rotation_locked_portrait_label
                    : R.string.quick_settings_rotation_locked_landscape_label;
            state.label = mContext.getString(label);
            icon = portrait ? mAutoToPortrait : mAutoToLandscape;
        } else {
            state.label = mContext.getString(R.string.quick_settings_rotation_unlocked_label);
            icon = portrait ? mPortraitToAuto : mLandscapeToAuto;
        }
        icon.setAllowAnimation(userInitiated);
        state.icon = icon;
        state.contentDescription = getAccessibilityString(rotationLocked,
                R.string.accessibility_rotation_lock_on_portrait,
                R.string.accessibility_rotation_lock_on_landscape,
                R.string.accessibility_rotation_lock_off);
    
protected BooleanStatenewTileState()

        return new BooleanState();
    
public voidsetListening(boolean listening)

        if (mController == null) return;
        if (listening) {
            mController.addRotationLockControllerCallback(mCallback);
        } else {
            mController.removeRotationLockControllerCallback(mCallback);
        }