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 ImageView mImageView;
|
||||||
private NfcAdapter mNfcAdapter;
|
private NfcAdapter mNfcAdapter;
|
||||||
private Switch mActionBarSwitch;
|
private Switch mActionBarSwitch;
|
||||||
|
private CharSequence mOldActivityTitle;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,7 +50,6 @@ public class AndroidBeam extends Fragment
|
|||||||
|
|
||||||
if (activity instanceof PreferenceActivity) {
|
if (activity instanceof PreferenceActivity) {
|
||||||
PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
|
PreferenceActivity preferenceActivity = (PreferenceActivity) activity;
|
||||||
if (preferenceActivity.onIsHidingHeaders() || !preferenceActivity.onIsMultiPane()) {
|
|
||||||
final int padding = activity.getResources().getDimensionPixelSize(
|
final int padding = activity.getResources().getDimensionPixelSize(
|
||||||
R.dimen.action_bar_switch_padding);
|
R.dimen.action_bar_switch_padding);
|
||||||
mActionBarSwitch.setPadding(0, 0, padding, 0);
|
mActionBarSwitch.setPadding(0, 0, padding, 0);
|
||||||
@@ -59,6 +59,8 @@ public class AndroidBeam extends Fragment
|
|||||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||||
Gravity.CENTER_VERTICAL | Gravity.END));
|
Gravity.CENTER_VERTICAL | Gravity.END));
|
||||||
|
if (!preferenceActivity.onIsMultiPane() || preferenceActivity.onIsHidingHeaders()) {
|
||||||
|
mOldActivityTitle = getActivity().getTitle();
|
||||||
activity.getActionBar().setTitle(R.string.android_beam_settings_title);
|
activity.getActionBar().setTitle(R.string.android_beam_settings_title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,6 +78,14 @@ public class AndroidBeam extends Fragment
|
|||||||
initView(mView);
|
initView(mView);
|
||||||
return 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) {
|
private void initView(View view) {
|
||||||
mActionBarSwitch.setOnCheckedChangeListener(this);
|
mActionBarSwitch.setOnCheckedChangeListener(this);
|
||||||
|
Reference in New Issue
Block a user