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

Commit 9b42335f authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Merge "Invert sense (and text) of rotation lock switch."

parents 7e48e76c 5920f153
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@
        <TextView
                android:id="@+id/rotate_label"
                style="@style/StatusBarPanelSettingsContents"
                android:text="@string/status_bar_settings_rotation_lock"
                android:text="@string/status_bar_settings_auto_rotation"
                />
        <Switch
                android:id="@+id/rotate_checkbox"
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@
    <string name="status_bar_settings_airplane">Airplane mode</string>

    <!-- Label in system panel saying the device will use the orientation sensor to rotate [CHAR LIMIT=30] -->
    <string name="status_bar_settings_rotation_lock">Lock screen orientation</string>
    <string name="status_bar_settings_auto_rotation">Auto-rotate screen</string>

    <!-- Abbreviation / label for mute brightness mode button. Should be all caps. [CHAR LIMIT=6] -->
    <string name="status_bar_settings_mute_label">MUTE</string>
+12 −12
Original line number Diff line number Diff line
@@ -35,39 +35,39 @@ public class AutoRotateController implements CompoundButton.OnCheckedChangeListe
    private Context mContext;
    private CompoundButton mCheckBox;

    private boolean mLockRotation;
    private boolean mAutoRotation;

    public AutoRotateController(Context context, CompoundButton checkbox) {
        mContext = context;
        mLockRotation = getLockRotation();
        mAutoRotation = getAutoRotation();
        mCheckBox = checkbox;
        checkbox.setChecked(mLockRotation);
        checkbox.setChecked(mAutoRotation);
        checkbox.setOnCheckedChangeListener(this);
    }

    public void onCheckedChanged(CompoundButton view, boolean checked) {
        if (checked != mLockRotation) {
            setLockRotation(checked);
        if (checked != mAutoRotation) {
            setAutoRotation(checked);
        }
    }

    private boolean getLockRotation() {
    private boolean getAutoRotation() {
        ContentResolver cr = mContext.getContentResolver();
        return 0 == Settings.System.getInt(cr, Settings.System.ACCELEROMETER_ROTATION, 0);
        return 0 != Settings.System.getInt(cr, Settings.System.ACCELEROMETER_ROTATION, 0);
    }

    private void setLockRotation(final boolean locked) {
        mLockRotation = locked;
    private void setAutoRotation(final boolean autorotate) {
        mAutoRotation = autorotate;
        AsyncTask.execute(new Runnable() {
                public void run() {
                    try {
                        IWindowManager wm = IWindowManager.Stub.asInterface(
                                ServiceManager.getService(Context.WINDOW_SERVICE));
                        ContentResolver cr = mContext.getContentResolver();
                        if (locked) {
                            wm.freezeRotation();
                        } else {
                        if (autorotate) {
                            wm.thawRotation();
                        } else {
                            wm.freezeRotation();
                        }
                    } catch (RemoteException exc) {
                    }