Track changes to brightness and orientation lock in Settings.

Bug: 3491814
Bug: 3482859
Bug: 3497535

Since the system bar can now change brightness and orientation lock, Settings needs to listen
to changes to those settings and reflect in the UI.

Also fix a problem with restoring state on cancel when the brightness dialog is invoked a
second time.

Change-Id: I3ada6e77df9a6b013a16061877fcb6b55c94a903
This commit is contained in:
Amith Yamasani
2011-02-28 17:24:31 -08:00
parent e18897bc22
commit 26a1f898e0
2 changed files with 94 additions and 18 deletions

View File

@@ -21,7 +21,9 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.preference.CheckBoxPreference;
@@ -53,6 +55,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
private ListPreference mScreenTimeoutPreference;
private ContentObserver mAccelerometerRotationObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
updateAccelerometerRotationCheckbox();
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -131,6 +140,16 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
super.onResume();
updateState(true);
getContentResolver().registerContentObserver(
Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION), true,
mAccelerometerRotationObserver);
}
@Override
public void onPause() {
super.onPause();
getContentResolver().unregisterContentObserver(mAccelerometerRotationObserver);
}
private void updateState(boolean force) {
@@ -159,6 +178,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
}
mAnimations.setValueIndex(idx);
updateAnimationsSummary(mAnimations.getValue());
updateAccelerometerRotationCheckbox();
}
private void updateAccelerometerRotationCheckbox() {
mAccelerometer.setChecked(Settings.System.getInt(
getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION, 0) != 0);