Fragmentize TetherSettings and WifiApSettings.
PreferenceScreen for BT tethering isn't fragmentized yet. We'll need to do so in the near future. Change-Id: I5a84fecaf84d55b59b6efa8151f2549ad37ca5db
This commit is contained in:
@@ -147,13 +147,14 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".wifi.WifiApSettings">
|
||||
<activity-alias android:name=".wifi.WifiApSettings"
|
||||
android:targetActivity="Settings">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</activity-alias>
|
||||
|
||||
<activity android:name="ApnSettings" android:label="@string/apn_settings"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
@@ -184,14 +185,15 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".TetherSettings"
|
||||
android:clearTaskOnLaunch="true">
|
||||
<activity-alias android:name=".TetherSettings"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:targetActivity="Settings">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.VOICE_LAUNCH" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</activity-alias>
|
||||
|
||||
<activity android:name=".vpn.VpnSettings"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
|
@@ -27,13 +27,10 @@
|
||||
android:persistent="false" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:fragment="com.android.settings.wifi.WifiApSettings"
|
||||
android:key="wifi_ap_settings"
|
||||
android:title="@string/wifi_tether_settings_text"
|
||||
android:summary="@string/wifi_tether_settings_subtext" >
|
||||
<intent
|
||||
android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:targetClass="com.android.settings.wifi.WifiApSettings" />
|
||||
</PreferenceScreen>
|
||||
|
||||
<CheckBoxPreference
|
||||
|
@@ -55,13 +55,10 @@
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
android:fragment="com.android.settings.TetherSettings"
|
||||
android:key="tether_settings"
|
||||
android:title="@string/tether_settings_title_all"
|
||||
android:summary="@string/tether_settings_summary_all">
|
||||
<intent
|
||||
android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.settings"
|
||||
android:targetClass="com.android.settings.TetherSettings" />
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen
|
||||
|
@@ -18,27 +18,22 @@ package com.android.settings;
|
||||
|
||||
import com.android.settings.wifi.WifiApEnabler;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothPan;
|
||||
import android.bluetooth.IBluetooth;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.AssetManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -48,7 +43,7 @@ import java.util.Locale;
|
||||
/*
|
||||
* Displays preferences for Tethering.
|
||||
*/
|
||||
public class TetherSettings extends PreferenceActivity {
|
||||
public class TetherSettings extends SettingsPreferenceFragment {
|
||||
private static final String TAG = "TetheringSettings";
|
||||
|
||||
private static final String USB_TETHER_SETTINGS = "usb_tether_settings";
|
||||
@@ -86,11 +81,16 @@ public class TetherSettings extends PreferenceActivity {
|
||||
private BluetoothPan mBluetoothPan;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
mBluetoothPan = new BluetoothPan(this);
|
||||
addPreferencesFromResource(R.xml.tether_prefs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final Activity activity = getActivity();
|
||||
mBluetoothPan = new BluetoothPan(activity);
|
||||
|
||||
mEnableWifiAp = (CheckBoxPreference) findPreference(ENABLE_WIFI_AP);
|
||||
mWifiApSettings = (PreferenceScreen) findPreference(WIFI_AP_SETTINGS);
|
||||
@@ -131,31 +131,31 @@ public class TetherSettings extends PreferenceActivity {
|
||||
}
|
||||
}
|
||||
if (wifiAvailable && usbAvailable && bluetoothAvailable){
|
||||
setTitle(R.string.tether_settings_title_all);
|
||||
activity.setTitle(R.string.tether_settings_title_all);
|
||||
} else if (wifiAvailable && usbAvailable){
|
||||
setTitle(R.string.tether_settings_title_all);
|
||||
activity.setTitle(R.string.tether_settings_title_all);
|
||||
} else if (wifiAvailable && bluetoothAvailable){
|
||||
setTitle(R.string.tether_settings_title_all);
|
||||
activity.setTitle(R.string.tether_settings_title_all);
|
||||
} else if (wifiAvailable) {
|
||||
setTitle(R.string.tether_settings_title_wifi);
|
||||
activity.setTitle(R.string.tether_settings_title_wifi);
|
||||
} else if (usbAvailable && bluetoothAvailable) {
|
||||
setTitle(R.string.tether_settings_title_usb_bluetooth);
|
||||
activity.setTitle(R.string.tether_settings_title_usb_bluetooth);
|
||||
} else if (usbAvailable) {
|
||||
setTitle(R.string.tether_settings_title_usb);
|
||||
activity.setTitle(R.string.tether_settings_title_usb);
|
||||
} else {
|
||||
setTitle(R.string.tether_settings_title_bluetooth);
|
||||
activity.setTitle(R.string.tether_settings_title_bluetooth);
|
||||
}
|
||||
mWifiApEnabler = new WifiApEnabler(this, mEnableWifiAp);
|
||||
mView = new WebView(this);
|
||||
mWifiApEnabler = new WifiApEnabler(activity, mEnableWifiAp);
|
||||
mView = new WebView(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
public Dialog onCreateDialog(int id) {
|
||||
if (id == DIALOG_TETHER_HELP) {
|
||||
Locale locale = Locale.getDefault();
|
||||
|
||||
// check for the full language + country resource, if not there, try just language
|
||||
AssetManager am = getAssets();
|
||||
final AssetManager am = getActivity().getAssets();
|
||||
String path = HELP_PATH.replace("%y", locale.getLanguage().toLowerCase());
|
||||
path = path.replace("%z", "_"+locale.getCountry().toLowerCase());
|
||||
boolean useCountry = true;
|
||||
@@ -185,7 +185,7 @@ public class TetherSettings extends PreferenceActivity {
|
||||
|
||||
mView.loadUrl(url);
|
||||
|
||||
return new AlertDialog.Builder(this)
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setCancelable(true)
|
||||
.setTitle(R.string.tethering_help_button_text)
|
||||
.setView(mView)
|
||||
@@ -218,31 +218,33 @@ public class TetherSettings extends PreferenceActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
final Activity activity = getActivity();
|
||||
|
||||
mTetherChangeReceiver = new TetherChangeReceiver();
|
||||
IntentFilter filter = new IntentFilter(ConnectivityManager.ACTION_TETHER_STATE_CHANGED);
|
||||
Intent intent = registerReceiver(mTetherChangeReceiver, filter);
|
||||
Intent intent = activity.registerReceiver(mTetherChangeReceiver, filter);
|
||||
|
||||
filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_MEDIA_SHARED);
|
||||
filter.addAction(Intent.ACTION_MEDIA_UNSHARED);
|
||||
filter.addDataScheme("file");
|
||||
registerReceiver(mTetherChangeReceiver, filter);
|
||||
activity.registerReceiver(mTetherChangeReceiver, filter);
|
||||
|
||||
filter = new IntentFilter();
|
||||
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
registerReceiver(mTetherChangeReceiver, filter);
|
||||
activity.registerReceiver(mTetherChangeReceiver, filter);
|
||||
|
||||
if (intent != null) mTetherChangeReceiver.onReceive(this, intent);
|
||||
if (intent != null) mTetherChangeReceiver.onReceive(activity, intent);
|
||||
mWifiApEnabler.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
unregisterReceiver(mTetherChangeReceiver);
|
||||
getActivity().unregisterReceiver(mTetherChangeReceiver);
|
||||
mTetherChangeReceiver = null;
|
||||
mWifiApEnabler.pause();
|
||||
}
|
||||
@@ -458,7 +460,8 @@ public class TetherSettings extends PreferenceActivity {
|
||||
} else if (preference == mTetherHelp) {
|
||||
showDialog(DIALOG_TETHER_HELP);
|
||||
}
|
||||
return false;
|
||||
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
|
||||
private String findIface(String[] ifaces, String[] regexes) {
|
||||
|
@@ -17,29 +17,24 @@
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
|
||||
import android.net.wifi.WifiConfiguration.KeyMgmt;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
/*
|
||||
* Displays preferences for Tethering.
|
||||
*/
|
||||
public class WifiApSettings extends PreferenceActivity
|
||||
public class WifiApSettings extends SettingsPreferenceFragment
|
||||
implements DialogInterface.OnClickListener {
|
||||
|
||||
private static final String WIFI_AP_SSID_AND_SECURITY = "wifi_ap_ssid_and_security";
|
||||
@@ -61,26 +56,34 @@ public class WifiApSettings extends PreferenceActivity
|
||||
private WifiConfiguration mWifiConfig = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.wifi_ap_settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final Activity activity = getActivity();
|
||||
|
||||
mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
||||
mWifiConfig = mWifiManager.getWifiApConfiguration();
|
||||
mSecurityType = getResources().getStringArray(R.array.wifi_ap_security);
|
||||
|
||||
addPreferencesFromResource(R.xml.wifi_ap_settings);
|
||||
|
||||
|
||||
mCreateNetwork = findPreference(WIFI_AP_SSID_AND_SECURITY);
|
||||
mEnableWifiAp = (CheckBoxPreference) findPreference(ENABLE_WIFI_AP);
|
||||
|
||||
mWifiApEnabler = new WifiApEnabler(this, mEnableWifiAp);
|
||||
mWifiApEnabler = new WifiApEnabler(activity, mEnableWifiAp);
|
||||
|
||||
if(mWifiConfig == null) {
|
||||
String s = getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
|
||||
mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),
|
||||
final String s = activity.getString(
|
||||
com.android.internal.R.string.wifi_tether_configure_ssid_default);
|
||||
mCreateNetwork.setSummary(String.format(activity.getString(CONFIG_SUBTEXT),
|
||||
s, mSecurityType[OPEN_INDEX]));
|
||||
} else {
|
||||
mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),
|
||||
mCreateNetwork.setSummary(String.format(activity.getString(CONFIG_SUBTEXT),
|
||||
mWifiConfig.SSID,
|
||||
mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
|
||||
mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
|
||||
@@ -88,22 +91,23 @@ public class WifiApSettings extends PreferenceActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
public Dialog onCreateDialog(int id) {
|
||||
if (id == DIALOG_AP_SETTINGS) {
|
||||
mDialog = new WifiApDialog(this, this, mWifiConfig);
|
||||
final Activity activity = getActivity();
|
||||
mDialog = new WifiApDialog(activity, this, mWifiConfig);
|
||||
return mDialog;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mWifiApEnabler.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mWifiApEnabler.pause();
|
||||
}
|
||||
@@ -117,7 +121,6 @@ public class WifiApSettings extends PreferenceActivity
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface dialogInterface, int button) {
|
||||
|
||||
if (button == DialogInterface.BUTTON_POSITIVE) {
|
||||
mWifiConfig = mDialog.getConfig();
|
||||
if (mWifiConfig != null) {
|
||||
@@ -135,7 +138,7 @@ public class WifiApSettings extends PreferenceActivity
|
||||
} else {
|
||||
mWifiManager.setWifiApConfiguration(mWifiConfig);
|
||||
}
|
||||
mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),
|
||||
mCreateNetwork.setSummary(String.format(getActivity().getString(CONFIG_SUBTEXT),
|
||||
mWifiConfig.SSID,
|
||||
mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
|
||||
mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
|
||||
|
Reference in New Issue
Block a user