Merge "Fix on/off switch for Android Beam." into jb-mr1-dev

This commit is contained in:
Martijn Coenen
2012-09-11 14:43:57 -07:00
committed by Android (Google) Code Review
52 changed files with 260 additions and 626 deletions

View File

@@ -64,17 +64,17 @@ final class LocalBluetoothPreferences {
return false;
}
// If Bluetooth Settings is visible
if (manager.isForegroundActivity()) {
return true;
}
// If in appliance mode, do not show dialog in foreground.
if ((context.getResources().getConfiguration().uiMode &
Configuration.UI_MODE_TYPE_APPLIANCE) == Configuration.UI_MODE_TYPE_APPLIANCE) {
return false;
}
// If Bluetooth Settings is visible
if (manager.isForegroundActivity()) {
return true;
}
long currentTimeMillis = System.currentTimeMillis();
SharedPreferences sharedPreferences = getSharedPreferences(context);

View File

@@ -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);