Fix on/off switch for Android Beam.
Bug: 7121720 Change-Id: Iec0f9ccfd439d11cfcc13afb45974ce1fd8778f0
This commit is contained in:
@@ -38,6 +38,7 @@ public class AndroidBeam extends Fragment
|
||||
private ImageView mImageView;
|
||||
private NfcAdapter mNfcAdapter;
|
||||
private Switch mActionBarSwitch;
|
||||
private CharSequence mOldActivityTitle;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -49,7 +50,6 @@ public class AndroidBeam extends Fragment
|
||||
|
||||
if (activity instanceof PreferenceActivity) {
|
||||
PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
|
||||
if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
|
||||
final int padding = activity.getResources().getDimensionPixelSize(
|
||||
R.dimen.action_bar_switch_padding);
|
||||
mActionBarSwitch.setPadding(0, 0, padding, 0);
|
||||
@@ -59,8 +59,10 @@ public class AndroidBeam extends Fragment
|
||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER_VERTICAL | Gravity.END));
|
||||
activity.getActionBar().setTitle(R.string.android_beam_settings_title);
|
||||
}
|
||||
if (!preferenceActivity.onIsMultiPane() || preferenceActivity.onIsHidingHeaders()) {
|
||||
mOldActivityTitle = getActivity().getTitle();
|
||||
activity.getActionBar().setTitle(R.string.android_beam_settings_title);
|
||||
}
|
||||
}
|
||||
|
||||
mActionBarSwitch.setOnCheckedChangeListener(this);
|
||||
@@ -76,6 +78,14 @@ public class AndroidBeam extends Fragment
|
||||
initView(mView);
|
||||
return mView;
|
||||
}
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
getActivity().getActionBar().setCustomView(null);
|
||||
if (mOldActivityTitle != null) {
|
||||
getActivity().getActionBar().setTitle(mOldActivityTitle);
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
mActionBarSwitch.setOnCheckedChangeListener(this);
|
||||
|
Reference in New Issue
Block a user