Kill the Switch on top-right after exiting Accounts & sync.
Bug: 5564377 - Bluetooth screen showing a Switch that doesn't follow the bluetooth setting. This seems to have been the Switch in Accounts & sync being set as a custom view for the Settings activity and not removed on changing fragments. Change-Id: I4575a769fbf5482048dbc4e912c6b6f782f505a0
This commit is contained in:
@@ -74,7 +74,14 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
AccountManager.get(getActivity()).addOnAccountsUpdatedListener(this, null, true);
|
Activity activity = getActivity();
|
||||||
|
AccountManager.get(activity).addOnAccountsUpdatedListener(this, null, true);
|
||||||
|
activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
|
||||||
|
ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||||
|
activity.getActionBar().setCustomView(mAutoSyncSwitch, new ActionBar.LayoutParams(
|
||||||
|
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||||
|
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.CENTER_VERTICAL | Gravity.RIGHT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -100,12 +107,6 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
final int padding = activity.getResources().getDimensionPixelSize(
|
final int padding = activity.getResources().getDimensionPixelSize(
|
||||||
R.dimen.action_bar_switch_padding);
|
R.dimen.action_bar_switch_padding);
|
||||||
mAutoSyncSwitch.setPadding(0, 0, padding, 0);
|
mAutoSyncSwitch.setPadding(0, 0, padding, 0);
|
||||||
activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
|
|
||||||
ActionBar.DISPLAY_SHOW_CUSTOM);
|
|
||||||
activity.getActionBar().setCustomView(mAutoSyncSwitch, new ActionBar.LayoutParams(
|
|
||||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
|
||||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
|
||||||
Gravity.CENTER_VERTICAL | Gravity.RIGHT));
|
|
||||||
mAutoSyncSwitch.setChecked(ContentResolver.getMasterSyncAutomatically());
|
mAutoSyncSwitch.setChecked(ContentResolver.getMasterSyncAutomatically());
|
||||||
mAutoSyncSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
mAutoSyncSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -123,7 +124,10 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
|||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
AccountManager.get(getActivity()).removeOnAccountsUpdatedListener(this);
|
final Activity activity = getActivity();
|
||||||
|
AccountManager.get(activity).removeOnAccountsUpdatedListener(this);
|
||||||
|
activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||||
|
activity.getActionBar().setCustomView(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user