Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java +27 −10 Original line number Original line Diff line number Diff line Loading @@ -18,32 +18,40 @@ package com.android.systemui.statusbar.policy; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.database.ContentObserver; import android.os.AsyncTask; import android.os.AsyncTask; import android.os.Handler; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.provider.Settings; import android.provider.Settings; import android.util.Log; import android.util.Log; import android.util.Slog; import android.view.IWindowManager; import android.view.IWindowManager; import android.widget.CompoundButton; import android.widget.CompoundButton; /** * TODO: Listen for changes to the setting. */ public class AutoRotateController implements CompoundButton.OnCheckedChangeListener { public class AutoRotateController implements CompoundButton.OnCheckedChangeListener { private static final String TAG = "StatusBar.AutoRotateController"; private static final String TAG = "StatusBar.AutoRotateController"; private Context mContext; private final Context mContext; private CompoundButton mCheckBox; private final CompoundButton mCheckbox; private boolean mAutoRotation; private boolean mAutoRotation; private ContentObserver mAccelerometerRotationObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { updateCheckbox(); } }; public AutoRotateController(Context context, CompoundButton checkbox) { public AutoRotateController(Context context, CompoundButton checkbox) { mContext = context; mContext = context; mAutoRotation = getAutoRotation(); mCheckbox = checkbox; mCheckBox = checkbox; updateCheckbox(); checkbox.setChecked(mAutoRotation); mCheckbox.setOnCheckedChangeListener(this); checkbox.setOnCheckedChangeListener(this); mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true, mAccelerometerRotationObserver); } } public void onCheckedChanged(CompoundButton view, boolean checked) { public void onCheckedChanged(CompoundButton view, boolean checked) { Loading @@ -52,6 +60,15 @@ public class AutoRotateController implements CompoundButton.OnCheckedChangeListe } } } } public void release() { mContext.getContentResolver().unregisterContentObserver(mAccelerometerRotationObserver); } private void updateCheckbox() { mAutoRotation = getAutoRotation(); mCheckbox.setChecked(mAutoRotation); } private boolean getAutoRotation() { private boolean getAutoRotation() { ContentResolver cr = mContext.getContentResolver(); 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); Loading packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -75,6 +75,7 @@ public class SettingsView extends LinearLayout implements View.OnClickListener { super.onDetachedFromWindow(); super.onDetachedFromWindow(); mAirplane.release(); mAirplane.release(); mDoNotDisturb.release(); mDoNotDisturb.release(); mRotate.release(); } } public void onClick(View v) { public void onClick(View v) { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/AutoRotateController.java +27 −10 Original line number Original line Diff line number Diff line Loading @@ -18,32 +18,40 @@ package com.android.systemui.statusbar.policy; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.database.ContentObserver; import android.os.AsyncTask; import android.os.AsyncTask; import android.os.Handler; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.provider.Settings; import android.provider.Settings; import android.util.Log; import android.util.Log; import android.util.Slog; import android.view.IWindowManager; import android.view.IWindowManager; import android.widget.CompoundButton; import android.widget.CompoundButton; /** * TODO: Listen for changes to the setting. */ public class AutoRotateController implements CompoundButton.OnCheckedChangeListener { public class AutoRotateController implements CompoundButton.OnCheckedChangeListener { private static final String TAG = "StatusBar.AutoRotateController"; private static final String TAG = "StatusBar.AutoRotateController"; private Context mContext; private final Context mContext; private CompoundButton mCheckBox; private final CompoundButton mCheckbox; private boolean mAutoRotation; private boolean mAutoRotation; private ContentObserver mAccelerometerRotationObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { updateCheckbox(); } }; public AutoRotateController(Context context, CompoundButton checkbox) { public AutoRotateController(Context context, CompoundButton checkbox) { mContext = context; mContext = context; mAutoRotation = getAutoRotation(); mCheckbox = checkbox; mCheckBox = checkbox; updateCheckbox(); checkbox.setChecked(mAutoRotation); mCheckbox.setOnCheckedChangeListener(this); checkbox.setOnCheckedChangeListener(this); mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true, mAccelerometerRotationObserver); } } public void onCheckedChanged(CompoundButton view, boolean checked) { public void onCheckedChanged(CompoundButton view, boolean checked) { Loading @@ -52,6 +60,15 @@ public class AutoRotateController implements CompoundButton.OnCheckedChangeListe } } } } public void release() { mContext.getContentResolver().unregisterContentObserver(mAccelerometerRotationObserver); } private void updateCheckbox() { mAutoRotation = getAutoRotation(); mCheckbox.setChecked(mAutoRotation); } private boolean getAutoRotation() { private boolean getAutoRotation() { ContentResolver cr = mContext.getContentResolver(); 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); Loading
packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -75,6 +75,7 @@ public class SettingsView extends LinearLayout implements View.OnClickListener { super.onDetachedFromWindow(); super.onDetachedFromWindow(); mAirplane.release(); mAirplane.release(); mDoNotDisturb.release(); mDoNotDisturb.release(); mRotate.release(); } } public void onClick(View v) { public void onClick(View v) { Loading