Loading res/layout/wifi_ap_dialog.xml +21 −24 Original line number Diff line number Diff line Loading @@ -67,30 +67,6 @@ android:prompt="@string/wifi_security" android:entries="@array/wifi_ap_security" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item_label" android:layout_marginTop="8dip" android:text="@string/wifi_ap_band_config" /> <RadioGroup android:id = "@+id/choose_channel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RadioButton android:id="@+id/ap_2G_band" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_ap_choose_2G" android:layout_marginTop="8dip"/> <RadioButton android:id="@+id/ap_5G_band" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_ap_choose_5G" android:layout_marginTop="8dip"/> </RadioGroup> </LinearLayout> <LinearLayout android:id="@+id/fields" Loading Loading @@ -130,5 +106,26 @@ style="@style/wifi_item_content" android:text="@string/wifi_show_password" /> </LinearLayout> <LinearLayout android:id="@+id/fields" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item_label" android:layout_marginTop="8dip" android:text="@string/wifi_ap_band_config" /> <Spinner android:id="@+id/choose_channel" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item_content" android:prompt="@string/wifi_ap_band_config" /> </LinearLayout> </LinearLayout> </ScrollView> res/values/arrays.xml +11 −0 Original line number Diff line number Diff line Loading @@ -324,6 +324,17 @@ <item>AKA\'</item> </string-array> <!-- Wi-Fi AP band settings. Either 2.4GHz or 5GHz. --> <!-- Note that adding/removing/moving the items will need wifi settings code change. --> <string-array name="wifi_ap_band_config_full"> <item>@string/wifi_ap_choose_2G</item> <item>@string/wifi_ap_choose_5G</item> </string-array> <string-array name="wifi_ap_band_config_2G_only"> <item>@string/wifi_ap_choose_2G</item> </string-array> <!-- Wi-Fi WPS setup for p2p connections. --> <!-- Note that adding/removing/moving the items will need wifi settings code change. --> <string-array name="wifi_p2p_wps_setup"> Loading src/com/android/settings/WifiCallingSettings.java +7 −4 Original line number Diff line number Diff line Loading @@ -178,10 +178,9 @@ public class WifiCallingSettings extends SettingsPreferenceFragment boolean wfcEnabled = ImsManager.isWfcEnabledByUser(context) && ImsManager.isNonTtyOrTtyOnVolteEnabled(context); mSwitch.setChecked(wfcEnabled); int wfcMode = ImsManager.getWfcMode(context); mButtonWfcMode.setValue(Integer.toString(wfcMode)); mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode)); updateButtonWfcMode(context, wfcEnabled, wfcMode); context.registerReceiver(mIntentReceiver, mIntentFilter); Loading Loading @@ -217,11 +216,15 @@ public class WifiCallingSettings extends SettingsPreferenceFragment ImsManager.setWfcSetting(context, isChecked); int wfcMode = ImsManager.getWfcMode(context); updateButtonWfcMode(context, isChecked, wfcMode); } private void updateButtonWfcMode(Context context, boolean wfcEnabled, int wfcMode) { mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode)); mButtonWfcMode.setEnabled(isChecked); mButtonWfcMode.setEnabled(wfcEnabled); final PreferenceScreen preferenceScreen = getPreferenceScreen(); if (isChecked) { if (wfcEnabled) { preferenceScreen.addPreference(mButtonWfcMode); } else { preferenceScreen.removePreference(mButtonWfcMode); Loading src/com/android/settings/wifi/WifiApDialog.java +42 −24 Original line number Diff line number Diff line Loading @@ -29,12 +29,11 @@ import android.text.InputType; import android.text.TextWatcher; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.RadioGroup; import android.widget.RadioButton; import com.android.settings.R; Loading @@ -58,12 +57,11 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, private TextView mSsid; private int mSecurityTypeIndex = OPEN_INDEX; private EditText mPassword; private RadioGroup mChannel; private RadioButton mChannel2G; private RadioButton mChannel5G; private int mBandIndex = OPEN_INDEX; WifiConfiguration mWifiConfig; WifiManager mWifiManager; private Context mContext; private static final String TAG = "WifiApDialog"; Loading @@ -76,6 +74,7 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, mSecurityTypeIndex = getSecurityTypeIndex(wifiConfig); } mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); mContext = context; } public static int getSecurityTypeIndex(WifiConfiguration wifiConfig) { Loading @@ -97,15 +96,7 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, */ config.SSID = mSsid.getText().toString(); //obtain the band configure if (mChannel2G.isChecked()) { config.apBand = 0; } else if(mChannel5G.isChecked()) { config.apBand = 1; } else { Log.e("TAG", "AP band configure error!"); return null; } config.apBand = mBandIndex; switch (mSecurityTypeIndex) { case OPEN_INDEX: Loading @@ -126,9 +117,10 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, @Override protected void onCreate(Bundle savedInstanceState) { boolean mInit = true; mView = getLayoutInflater().inflate(R.layout.wifi_ap_dialog, null); Spinner mSecurity = ((Spinner) mView.findViewById(R.id.security)); final Spinner mChannel = (Spinner) mView.findViewById(R.id.choose_channel); setView(mView); setInverseBackgroundForced(true); Loading @@ -140,20 +132,20 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, mSsid = (TextView) mView.findViewById(R.id.ssid); mPassword = (EditText) mView.findViewById(R.id.password); mChannel = (RadioGroup) mView.findViewById(R.id.choose_channel); mChannel2G = (RadioButton) mView.findViewById(R.id.ap_2G_band); mChannel5G = (RadioButton) mView.findViewById(R.id.ap_5G_band); ArrayAdapter <CharSequence> channelAdapter; String countryCode = mWifiManager.getCountryCode(); if (!mWifiManager.is5GHzBandSupported() || countryCode == null) { //If no country code, 5GHz AP is forbidden Log.e(TAG," NO country code, forbid 5GHz"); mChannel5G.setVisibility(View.INVISIBLE); Log.i(TAG," NO country code, forbid 5GHz"); channelAdapter = ArrayAdapter.createFromResource(mContext, R.array.wifi_ap_band_config_2G_only, android.R.layout.simple_spinner_item); mWifiConfig.apBand = 0; } else { mChannel5G.setVisibility(View.VISIBLE); channelAdapter = ArrayAdapter.createFromResource(mContext, R.array.wifi_ap_band_config_full, android.R.layout.simple_spinner_item); } channelAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); setButton(BUTTON_SUBMIT, context.getString(R.string.wifi_save), mListener); setButton(DialogInterface.BUTTON_NEGATIVE, Loading @@ -162,9 +154,9 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, if (mWifiConfig != null) { mSsid.setText(mWifiConfig.SSID); if (mWifiConfig.apBand == 0) { mChannel2G.setChecked(true); mBandIndex = 0; } else { mChannel5G.setChecked(true); mBandIndex = 1; } mSecurity.setSelection(mSecurityTypeIndex); Loading @@ -173,6 +165,32 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, } } mChannel.setAdapter(channelAdapter); mChannel.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { boolean mInit = true; @Override public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { if (!mInit) { mBandIndex = position; mWifiConfig.apBand = mBandIndex; Log.i(TAG, "config on channelIndex : " + mBandIndex + " Band: " + mWifiConfig.apBand); } else { mInit = false; mChannel.setSelection(mBandIndex); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } } ); mSsid.addTextChangedListener(this); mPassword.addTextChangedListener(this); ((CheckBox) mView.findViewById(R.id.show_password)).setOnClickListener(this); Loading Loading
res/layout/wifi_ap_dialog.xml +21 −24 Original line number Diff line number Diff line Loading @@ -67,30 +67,6 @@ android:prompt="@string/wifi_security" android:entries="@array/wifi_ap_security" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item_label" android:layout_marginTop="8dip" android:text="@string/wifi_ap_band_config" /> <RadioGroup android:id = "@+id/choose_channel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RadioButton android:id="@+id/ap_2G_band" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_ap_choose_2G" android:layout_marginTop="8dip"/> <RadioButton android:id="@+id/ap_5G_band" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/wifi_ap_choose_5G" android:layout_marginTop="8dip"/> </RadioGroup> </LinearLayout> <LinearLayout android:id="@+id/fields" Loading Loading @@ -130,5 +106,26 @@ style="@style/wifi_item_content" android:text="@string/wifi_show_password" /> </LinearLayout> <LinearLayout android:id="@+id/fields" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item_label" android:layout_marginTop="8dip" android:text="@string/wifi_ap_band_config" /> <Spinner android:id="@+id/choose_channel" android:layout_width="match_parent" android:layout_height="wrap_content" style="@style/wifi_item_content" android:prompt="@string/wifi_ap_band_config" /> </LinearLayout> </LinearLayout> </ScrollView>
res/values/arrays.xml +11 −0 Original line number Diff line number Diff line Loading @@ -324,6 +324,17 @@ <item>AKA\'</item> </string-array> <!-- Wi-Fi AP band settings. Either 2.4GHz or 5GHz. --> <!-- Note that adding/removing/moving the items will need wifi settings code change. --> <string-array name="wifi_ap_band_config_full"> <item>@string/wifi_ap_choose_2G</item> <item>@string/wifi_ap_choose_5G</item> </string-array> <string-array name="wifi_ap_band_config_2G_only"> <item>@string/wifi_ap_choose_2G</item> </string-array> <!-- Wi-Fi WPS setup for p2p connections. --> <!-- Note that adding/removing/moving the items will need wifi settings code change. --> <string-array name="wifi_p2p_wps_setup"> Loading
src/com/android/settings/WifiCallingSettings.java +7 −4 Original line number Diff line number Diff line Loading @@ -178,10 +178,9 @@ public class WifiCallingSettings extends SettingsPreferenceFragment boolean wfcEnabled = ImsManager.isWfcEnabledByUser(context) && ImsManager.isNonTtyOrTtyOnVolteEnabled(context); mSwitch.setChecked(wfcEnabled); int wfcMode = ImsManager.getWfcMode(context); mButtonWfcMode.setValue(Integer.toString(wfcMode)); mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode)); updateButtonWfcMode(context, wfcEnabled, wfcMode); context.registerReceiver(mIntentReceiver, mIntentFilter); Loading Loading @@ -217,11 +216,15 @@ public class WifiCallingSettings extends SettingsPreferenceFragment ImsManager.setWfcSetting(context, isChecked); int wfcMode = ImsManager.getWfcMode(context); updateButtonWfcMode(context, isChecked, wfcMode); } private void updateButtonWfcMode(Context context, boolean wfcEnabled, int wfcMode) { mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode)); mButtonWfcMode.setEnabled(isChecked); mButtonWfcMode.setEnabled(wfcEnabled); final PreferenceScreen preferenceScreen = getPreferenceScreen(); if (isChecked) { if (wfcEnabled) { preferenceScreen.addPreference(mButtonWfcMode); } else { preferenceScreen.removePreference(mButtonWfcMode); Loading
src/com/android/settings/wifi/WifiApDialog.java +42 −24 Original line number Diff line number Diff line Loading @@ -29,12 +29,11 @@ import android.text.InputType; import android.text.TextWatcher; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; import android.widget.RadioGroup; import android.widget.RadioButton; import com.android.settings.R; Loading @@ -58,12 +57,11 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, private TextView mSsid; private int mSecurityTypeIndex = OPEN_INDEX; private EditText mPassword; private RadioGroup mChannel; private RadioButton mChannel2G; private RadioButton mChannel5G; private int mBandIndex = OPEN_INDEX; WifiConfiguration mWifiConfig; WifiManager mWifiManager; private Context mContext; private static final String TAG = "WifiApDialog"; Loading @@ -76,6 +74,7 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, mSecurityTypeIndex = getSecurityTypeIndex(wifiConfig); } mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); mContext = context; } public static int getSecurityTypeIndex(WifiConfiguration wifiConfig) { Loading @@ -97,15 +96,7 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, */ config.SSID = mSsid.getText().toString(); //obtain the band configure if (mChannel2G.isChecked()) { config.apBand = 0; } else if(mChannel5G.isChecked()) { config.apBand = 1; } else { Log.e("TAG", "AP band configure error!"); return null; } config.apBand = mBandIndex; switch (mSecurityTypeIndex) { case OPEN_INDEX: Loading @@ -126,9 +117,10 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, @Override protected void onCreate(Bundle savedInstanceState) { boolean mInit = true; mView = getLayoutInflater().inflate(R.layout.wifi_ap_dialog, null); Spinner mSecurity = ((Spinner) mView.findViewById(R.id.security)); final Spinner mChannel = (Spinner) mView.findViewById(R.id.choose_channel); setView(mView); setInverseBackgroundForced(true); Loading @@ -140,20 +132,20 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, mSsid = (TextView) mView.findViewById(R.id.ssid); mPassword = (EditText) mView.findViewById(R.id.password); mChannel = (RadioGroup) mView.findViewById(R.id.choose_channel); mChannel2G = (RadioButton) mView.findViewById(R.id.ap_2G_band); mChannel5G = (RadioButton) mView.findViewById(R.id.ap_5G_band); ArrayAdapter <CharSequence> channelAdapter; String countryCode = mWifiManager.getCountryCode(); if (!mWifiManager.is5GHzBandSupported() || countryCode == null) { //If no country code, 5GHz AP is forbidden Log.e(TAG," NO country code, forbid 5GHz"); mChannel5G.setVisibility(View.INVISIBLE); Log.i(TAG," NO country code, forbid 5GHz"); channelAdapter = ArrayAdapter.createFromResource(mContext, R.array.wifi_ap_band_config_2G_only, android.R.layout.simple_spinner_item); mWifiConfig.apBand = 0; } else { mChannel5G.setVisibility(View.VISIBLE); channelAdapter = ArrayAdapter.createFromResource(mContext, R.array.wifi_ap_band_config_full, android.R.layout.simple_spinner_item); } channelAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); setButton(BUTTON_SUBMIT, context.getString(R.string.wifi_save), mListener); setButton(DialogInterface.BUTTON_NEGATIVE, Loading @@ -162,9 +154,9 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, if (mWifiConfig != null) { mSsid.setText(mWifiConfig.SSID); if (mWifiConfig.apBand == 0) { mChannel2G.setChecked(true); mBandIndex = 0; } else { mChannel5G.setChecked(true); mBandIndex = 1; } mSecurity.setSelection(mSecurityTypeIndex); Loading @@ -173,6 +165,32 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, } } mChannel.setAdapter(channelAdapter); mChannel.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { boolean mInit = true; @Override public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { if (!mInit) { mBandIndex = position; mWifiConfig.apBand = mBandIndex; Log.i(TAG, "config on channelIndex : " + mBandIndex + " Band: " + mWifiConfig.apBand); } else { mInit = false; mChannel.setSelection(mBandIndex); } } @Override public void onNothingSelected(AdapterView<?> adapterView) { } } ); mSsid.addTextChangedListener(this); mPassword.addTextChangedListener(this); ((CheckBox) mView.findViewById(R.id.show_password)).setOnClickListener(this); Loading