Introduce SwitchBar widget
- SwitchBar is a LinearLayout that containts a TextView and a Switch and is intended to replace all Switches that are put in the ActionBar as a custom view - use the new SwitchBar for WifiSetting only for now (a later CL will take care of all the other Setting that are using a Switch in the ActionBar) Related to bug #14898161 On/Off switches must move down from Action Bar Change-Id: I5e98dbe995bba8f440d08459e09ca3ac09d3464b
This commit is contained in:
@@ -19,13 +19,13 @@ package com.android.settings.wifi;
|
||||
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
|
||||
import static android.os.UserManager.DISALLOW_CONFIG_WIFI;
|
||||
|
||||
import android.preference.PreferenceActivity;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedSettingsFragment;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settings.wifi.p2p.WifiP2pSettings;
|
||||
|
||||
import android.app.ActionBar;
|
||||
@@ -179,7 +179,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
// the action bar uses a different set of controls for Setup Wizard
|
||||
private boolean mSetupWizardMode;
|
||||
|
||||
private Switch mSwitch;
|
||||
private SwitchBar mSwitchBar;
|
||||
|
||||
/* End of "used in Wifi Setup context" */
|
||||
|
||||
@@ -413,32 +413,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
|
||||
// On/off switch is hidden for Setup Wizard
|
||||
if (!mSetupWizardMode) {
|
||||
final Activity activity = getActivity();
|
||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||
|
||||
mSwitch = new Switch(activity.getActionBar().getThemedContext());
|
||||
|
||||
final int padding = activity.getResources().getDimensionPixelSize(
|
||||
R.dimen.action_bar_switch_padding);
|
||||
mSwitch.setPaddingRelative(0, 0, padding, 0);
|
||||
|
||||
activity.getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
|
||||
ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
activity.getActionBar().setCustomView(mSwitch, new ActionBar.LayoutParams(
|
||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||
ActionBar.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER_VERTICAL | Gravity.END));
|
||||
|
||||
mWifiEnabler = new WifiEnabler(activity, mSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (!mSetupWizardMode) {
|
||||
final Activity activity = getActivity();
|
||||
activity.getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
activity.getActionBar().setCustomView(null);
|
||||
mSwitchBar = activity.getSwitchBar();
|
||||
mWifiEnabler = new WifiEnabler(activity, mSwitchBar);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user