Merge branch 'master' into honeycomb-release

This commit is contained in:
The Android Automerger
2010-11-15 07:59:40 -08:00
14 changed files with 134 additions and 139 deletions

View File

@@ -130,7 +130,8 @@
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity android:name=".wifi.WifiInfo"> <activity android:name=".wifi.WifiInfo"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" /> <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -138,7 +139,8 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".wifi.WifiConfigInfo"> <activity android:name=".wifi.WifiConfigInfo"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" /> <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -146,7 +148,8 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".wifi.WifiAPITest"> <activity android:name=".wifi.WifiAPITest"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" /> <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -154,7 +157,8 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".wifi.WifiStatusTest"> <activity android:name=".wifi.WifiStatusTest"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" /> <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -163,7 +167,7 @@
</activity> </activity>
<activity-alias android:name=".wifi.WifiApSettings" <activity-alias android:name=".wifi.WifiApSettings"
android:targetActivity="Settings"> android:targetActivity="Settings">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@@ -311,7 +315,8 @@
</activity> </activity>
<activity android:name="PhysicalKeyboardSettings" <activity android:name="PhysicalKeyboardSettings"
android:label="@string/builtin_keyboard_settings_title"> android:label="@string/builtin_keyboard_settings_title"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@@ -391,7 +396,7 @@
</activity> </activity>
<activity android:name="Settings$DeviceInfoSettingsActivity" <activity android:name="Settings$DeviceInfoSettingsActivity"
android:theme="@android:style/Theme.Holo.Extended" android:theme="@android:style/Theme.Holo.DialogWhenLarge"
android:label="@string/device_info_settings"> android:label="@string/device_info_settings">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -407,7 +412,7 @@
<activity android:name="SettingsLicenseActivity" <activity android:name="SettingsLicenseActivity"
android:label="@string/settings_license_activity_title" android:label="@string/settings_license_activity_title"
android:theme="@*android:style/Theme.Dialog.Alert"> android:theme="@*android:style/Theme.Holo.Dialog.Alert">
<intent-filter> <intent-filter>
<action android:name="android.settings.LICENSE" /> <action android:name="android.settings.LICENSE" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@@ -416,7 +421,7 @@
<activity android:name="SettingsSafetyLegalActivity" <activity android:name="SettingsSafetyLegalActivity"
android:label="@string/settings_safetylegal_activity_title" android:label="@string/settings_safetylegal_activity_title"
android:theme="@*android:style/Theme.Dialog.Alert"> android:theme="@*android:style/Theme.Holo.Dialog.Alert">
<intent-filter> <intent-filter>
<action android:name="android.settings.SAFETY" /> <action android:name="android.settings.SAFETY" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
@@ -586,7 +591,9 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="IccLockSettings" android:label="@string/sim_lock_settings" <activity android:name="IccLockSettings"
android:label="@string/sim_lock_settings"
android:theme="@android:style/Theme.Holo.DialogWhenLarge"
android:process="com.android.phone"> android:process="com.android.phone">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -667,7 +674,9 @@
</activity> </activity>
<!-- Runs in the phone process since it needs access to the Phone object --> <!-- Runs in the phone process since it needs access to the Phone object -->
<activity android:name=".deviceinfo.Status" android:label="@string/device_status_activity_title" <activity android:name=".deviceinfo.Status"
android:label="@string/device_status_activity_title"
android:theme="@android:style/Theme.Holo.DialogWhenLarge"
android:process="com.android.phone"> android:process="com.android.phone">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -692,7 +701,9 @@
android:resource="@id/storage_settings" /> android:resource="@id/storage_settings" />
</activity> </activity>
<activity android:name="ApnEditor" android:label="@string/apn_edit"> <activity android:name="ApnEditor"
android:label="@string/apn_edit"
android:theme="@android:style/Theme.Holo.DialogWhenLarge">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" /> <action android:name="android.intent.action.EDIT" />

View File

@@ -2711,6 +2711,8 @@ found in the list of installed applications.</string>
<string name="vpn_type_title">Add VPN</string> <string name="vpn_type_title">Add VPN</string>
<!-- "Add VPN" preference title --> <!-- "Add VPN" preference title -->
<string name="vpn_add_new_vpn">Add VPN</string> <string name="vpn_add_new_vpn">Add VPN</string>
<!-- VPN details screen title -->
<string name="vpn_details_title">VPN details</string>
<!-- VPN profile editor title when adding a new profile --> <!-- VPN profile editor title when adding a new profile -->
<string name="vpn_edit_title_add">Add <xliff:g id="name">%s</xliff:g> VPN</string> <string name="vpn_edit_title_add">Add <xliff:g id="name">%s</xliff:g> VPN</string>
<!-- VPN profile editor title when editing an existing profile --> <!-- VPN profile editor title when editing an existing profile -->

View File

@@ -79,7 +79,7 @@
<item name="android:windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item>
</style> </style>
<style name="Theme.CreateShortCut" parent="android:Theme.Holo"> <style name="Theme.CreateShortCut" parent="android:Theme.Holo.DialogWhenLarge">
</style> </style>
</resources> </resources>

View File

@@ -35,11 +35,9 @@
<PreferenceScreen <PreferenceScreen
android:key="power_usage" android:key="power_usage"
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
android:title="@string/power_usage_summary_title" android:title="@string/power_usage_summary_title"
android:summary="@string/power_usage_summary"> android:summary="@string/power_usage_summary">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.fuelgauge.PowerUsageSummary" />
</PreferenceScreen> </PreferenceScreen>
<!-- Legal Information --> <!-- Legal Information -->

View File

@@ -63,50 +63,12 @@ public class SettingsPreferenceFragment extends PreferenceFragment
private Button mNextButton; private Button mNextButton;
@Override
public void onResume() {
super.onResume();
final Fragment f = getTargetFragment();
final int requestCode = getTargetRequestCode();
// TargetFragment becomes invalid when this object is resumed. Notify it to
// FragmentManager. Without this code, FragmentManager wrongly take the TargetFragment
// as live, and throws IllegalStateException.
setTargetFragment(null, -1);
if (f != null && (f instanceof SettingsPreferenceFragment)) {
final SettingsPreferenceFragment spf = (SettingsPreferenceFragment)f;
final int resultCode = spf.getResultCode();
final Intent resultData = spf.getResultData();
onActivityResult(requestCode, resultCode, resultData);
}
}
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
setupButtonBar(); setupButtonBar();
} }
public final void setResult(int resultCode) {
mResultCode = resultCode;
mResultData = null;
}
public final void setResult(int resultCode, Intent data) {
mResultCode = resultCode;
mResultData = data;
}
public final int getResultCode() {
return mResultCode;
}
public final Intent getResultData() {
return mResultData;
}
/* /*
* The name is intentionally made different from Activity#finish(), so that * The name is intentionally made different from Activity#finish(), so that
* users won't misunderstand its meaning. * users won't misunderstand its meaning.
@@ -196,9 +158,8 @@ public class SettingsPreferenceFragment extends PreferenceFragment
Fragment caller, String fragmentClass, int requestCode, Bundle extras) { Fragment caller, String fragmentClass, int requestCode, Bundle extras) {
if (getActivity() instanceof PreferenceActivity) { if (getActivity() instanceof PreferenceActivity) {
PreferenceActivity preferenceActivity = (PreferenceActivity)getActivity(); PreferenceActivity preferenceActivity = (PreferenceActivity)getActivity();
Fragment f = Fragment.instantiate(getActivity(), fragmentClass, extras); preferenceActivity.startPreferencePanel(fragmentClass, extras, 0, null, caller,
caller.setTargetFragment(f, requestCode); requestCode);
preferenceActivity.switchToHeader(fragmentClass, extras);
return true; return true;
} else { } else {
Log.w(TAG, "Parent isn't PreferenceActivity, thus there's no way to launch the " Log.w(TAG, "Parent isn't PreferenceActivity, thus there's no way to launch the "

View File

@@ -42,8 +42,14 @@ import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.android.settings.DisplaySettings;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SecuritySettings;
import com.android.settings.WirelessSettings;
import com.android.settings.applications.InstalledAppDetails; import com.android.settings.applications.InstalledAppDetails;
import com.android.settings.bluetooth.BluetoothSettings;
import com.android.settings.wifi.WifiSettings;
public class PowerUsageDetail extends Fragment implements Button.OnClickListener { public class PowerUsageDetail extends Fragment implements Button.OnClickListener {
@@ -253,24 +259,30 @@ public class PowerUsageDetail extends Fragment implements Button.OnClickListener
} }
private void doAction(int action) { private void doAction(int action) {
PreferenceActivity pa = (PreferenceActivity)getActivity();
switch (action) { switch (action) {
case ACTION_DISPLAY_SETTINGS: case ACTION_DISPLAY_SETTINGS:
startActivity(new Intent(Settings.ACTION_DISPLAY_SETTINGS)); pa.startPreferencePanel(DisplaySettings.class.getName(), null,
R.string.display_settings_title, null, null, 0);
break; break;
case ACTION_WIFI_SETTINGS: case ACTION_WIFI_SETTINGS:
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); pa.startPreferencePanel(WifiSettings.class.getName(), null,
R.string.wifi_settings, null, null, 0);
break; break;
case ACTION_BLUETOOTH_SETTINGS: case ACTION_BLUETOOTH_SETTINGS:
startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS)); pa.startPreferencePanel(BluetoothSettings.class.getName(), null,
R.string.bluetooth_settings, null, null, 0);
break; break;
case ACTION_WIRELESS_SETTINGS: case ACTION_WIRELESS_SETTINGS:
startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); pa.startPreferencePanel(WirelessSettings.class.getName(), null,
R.string.radio_controls_title, null, null, 0);
break; break;
case ACTION_APP_DETAILS: case ACTION_APP_DETAILS:
startApplicationDetailsActivity(); startApplicationDetailsActivity();
break; break;
case ACTION_SECURITY_SETTINGS: case ACTION_SECURITY_SETTINGS:
startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS)); pa.startPreferencePanel(SecuritySettings.class.getName(), null,
R.string.security_settings_title, null, null, 0);
break; break;
case ACTION_FORCE_STOP: case ACTION_FORCE_STOP:
killProcesses(); killProcesses();

View File

@@ -52,8 +52,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
final TextUtils.SimpleStringSplitter mStringColonSplitter final TextUtils.SimpleStringSplitter mStringColonSplitter
= new TextUtils.SimpleStringSplitter(':'); = new TextUtils.SimpleStringSplitter(':');
private String mLastTickedInputMethodId;
private AlertDialog mDialog = null; private AlertDialog mDialog = null;
@@ -145,7 +143,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties); this, getContentResolver(), mInputMethodProperties);
mLastTickedInputMethodId = null;
if (mLanguagePref != null) { if (mLanguagePref != null) {
Configuration conf = getResources().getConfiguration(); Configuration conf = getResources().getConfiguration();
@@ -161,7 +158,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId); mInputMethodProperties, mHaveHardKeyboard);
} }
@Override @Override
@@ -184,7 +181,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
selImi = imi; selImi = imi;
if (isSystemIme(imi)) { if (isSystemIme(imi)) {
// This is a built-in IME, so no need to warn. // This is a built-in IME, so no need to warn.
mLastTickedInputMethodId = id;
return super.onPreferenceTreeClick(preferenceScreen, preference); return super.onPreferenceTreeClick(preferenceScreen, preference);
} }
} }
@@ -203,7 +199,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
chkPref.setChecked(true); chkPref.setChecked(true);
mLastTickedInputMethodId = id;
} }
}) })
@@ -223,8 +218,6 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment {
R.string.ime_security_warning, R.string.ime_security_warning,
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager()))); selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show(); mDialog.show();
} else if (id.equals(mLastTickedInputMethodId)) {
mLastTickedInputMethodId = null;
} }
} else if (preference instanceof PreferenceScreen) { } else if (preference instanceof PreferenceScreen) {
if (preference.getFragment() != null) { if (preference.getFragment() != null) {

View File

@@ -42,8 +42,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
private List<InputMethodInfo> mInputMethodProperties; private List<InputMethodInfo> mInputMethodProperties;
private String mLastTickedInputMethodId;
private AlertDialog mDialog = null; private AlertDialog mDialog = null;
@Override @Override
@@ -60,14 +58,13 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
super.onResume(); super.onResume();
InputMethodAndSubtypeUtil.loadInputMethodSubtypeList( InputMethodAndSubtypeUtil.loadInputMethodSubtypeList(
this, getContentResolver(), mInputMethodProperties); this, getContentResolver(), mInputMethodProperties);
mLastTickedInputMethodId = null;
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(),
mInputMethodProperties, mHaveHardKeyboard, mLastTickedInputMethodId); mInputMethodProperties, mHaveHardKeyboard);
} }
@Override @Override
@@ -89,7 +86,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
this, mInputMethodProperties, id, true); this, mInputMethodProperties, id, true);
// This is a built-in IME, so no need to warn. // This is a built-in IME, so no need to warn.
mLastTickedInputMethodId = id;
return super.onPreferenceTreeClick(preferenceScreen, preference); return super.onPreferenceTreeClick(preferenceScreen, preference);
} }
break; break;
@@ -111,7 +107,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
InputMethodAndSubtypeEnabler.this, InputMethodAndSubtypeEnabler.this,
mInputMethodProperties, id, true); mInputMethodProperties, id, true);
mLastTickedInputMethodId = id;
} }
}) })
@@ -132,9 +127,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment {
selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager()))); selImi.getServiceInfo().applicationInfo.loadLabel(getPackageManager())));
mDialog.show(); mDialog.show();
} else { } else {
if (id.equals(mLastTickedInputMethodId)) {
mLastTickedInputMethodId = null;
}
InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled( InputMethodAndSubtypeUtil.setSubtypesPreferenceEnabled(
this, mInputMethodProperties, id, false); this, mInputMethodProperties, id, false);
} }

View File

@@ -98,15 +98,13 @@ public class InputMethodAndSubtypeUtil {
public static void saveInputMethodSubtypeList( public static void saveInputMethodSubtypeList(
SettingsPreferenceFragment context, ContentResolver resolver, SettingsPreferenceFragment context, ContentResolver resolver,
List<InputMethodInfo> inputMethodProperties, List<InputMethodInfo> inputMethodProperties, boolean hasHardKeyboard) {
boolean hasHardKeyboard, String lastTickedInputMethodId) {
String currentInputMethodId = Settings.Secure.getString(resolver, String currentInputMethodId = Settings.Secure.getString(resolver,
Settings.Secure.DEFAULT_INPUT_METHOD); Settings.Secure.DEFAULT_INPUT_METHOD);
final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver); final int selectedInputMethodSubtype = getInputMethodSubtypeSelected(resolver);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
StringBuilder disabledSysImes = new StringBuilder(); StringBuilder disabledSysImes = new StringBuilder();
InputMethodInfo firstEnabledIMI = null;
int firstSubtypeHashCode = NOT_A_SUBTYPE_ID; int firstSubtypeHashCode = NOT_A_SUBTYPE_ID;
final boolean onlyOneIME = inputMethodProperties.size() == 1; final boolean onlyOneIME = inputMethodProperties.size() == 1;
@@ -121,9 +119,6 @@ public class InputMethodAndSubtypeUtil {
|| (pref != null && pref.isChecked())) { || (pref != null && pref.isChecked())) {
if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER); if (builder.length() > 0) builder.append(INPUT_METHOD_SEPARATER);
builder.append(id); builder.append(id);
if (firstEnabledIMI == null) {
firstEnabledIMI = property;
}
for (InputMethodSubtype subtype : property.getSubtypes()) { for (InputMethodSubtype subtype : property.getSubtypes()) {
CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference( CheckBoxPreference subtypePref = (CheckBoxPreference) context.findPreference(
id + subtype.hashCode()); id + subtype.hashCode());
@@ -141,8 +136,11 @@ public class InputMethodAndSubtypeUtil {
} else if (isCurrentInputMethod) { } else if (isCurrentInputMethod) {
// We are processing the current input method, but found that it's not enabled. // We are processing the current input method, but found that it's not enabled.
// This means that the current input method has been uninstalled. // This means that the current input method has been uninstalled.
// If currentInputMethod is already uninstalled, selects last ticked IME // If currentInputMethod is already uninstalled, InputMethodManagerService will
currentInputMethodId = lastTickedInputMethodId; // find the applicable IME from the history and the system locale.
if (DEBUG) {
Log.d(TAG, "Current IME was uninstalled or disabled.");
}
} }
// If it's a disabled system ime, add it to the disabled list so that it // If it's a disabled system ime, add it to the disabled list so that it
// doesn't get enabled automatically on any changes to the package list // doesn't get enabled automatically on any changes to the package list
@@ -152,15 +150,6 @@ public class InputMethodAndSubtypeUtil {
} }
} }
// If the last input method is unset, set it as the first enabled one.
if (TextUtils.isEmpty(currentInputMethodId)) {
if (firstEnabledIMI != null) {
currentInputMethodId = firstEnabledIMI.getId();
} else {
currentInputMethodId = null;
}
}
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString()); Log.d(TAG, "--- Save enabled inputmethod settings. :" + builder.toString());
Log.d(TAG, "--- Save disable system inputmethod settings. :" Log.d(TAG, "--- Save disable system inputmethod settings. :"
@@ -183,6 +172,8 @@ public class InputMethodAndSubtypeUtil {
Settings.Secure.ENABLED_INPUT_METHODS, builder.toString()); Settings.Secure.ENABLED_INPUT_METHODS, builder.toString());
Settings.Secure.putString(resolver, Settings.Secure.putString(resolver,
Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString()); Settings.Secure.DISABLED_SYSTEM_INPUT_METHODS, disabledSysImes.toString());
// If the current input method is unset, InputMethodManagerService will find the applicable
// IME from the history and the system locale.
Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD, Settings.Secure.putString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD,
currentInputMethodId != null ? currentInputMethodId : ""); currentInputMethodId != null ? currentInputMethodId : "");
} }

View File

@@ -32,8 +32,8 @@ import android.net.vpn.VpnProfile;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.preference.PreferenceActivity;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@@ -109,7 +109,11 @@ public class VpnEditor extends SettingsPreferenceFragment {
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case MENU_SAVE: case MENU_SAVE:
if (validateAndSetResult()) finishFragment(); Intent resultIntent = validateAndGetResult();
if (resultIntent != null) {
((PreferenceActivity) getActivity()).finishPreferencePanel(
this, Activity.RESULT_OK, resultIntent);
}
return true; return true;
case MENU_CANCEL: case MENU_CANCEL:
@@ -152,22 +156,24 @@ public class VpnEditor extends SettingsPreferenceFragment {
* Checks the validity of the inputs and set the profile as result if valid. * Checks the validity of the inputs and set the profile as result if valid.
* @return true if the result is successfully set * @return true if the result is successfully set
*/ */
private boolean validateAndSetResult() { private Intent validateAndGetResult() {
String errorMsg = mProfileEditor.validate(); String errorMsg = mProfileEditor.validate();
if (errorMsg != null) { if (errorMsg != null) {
Util.showErrorMessage(getActivity(), errorMsg); Util.showErrorMessage(getActivity(), errorMsg);
return false; return null;
} }
if (profileChanged()) setResult(getProfile()); if (profileChanged()) {
return true; return getResult(getProfile());
}
return null;
} }
private void setResult(VpnProfile p) { private Intent getResult(VpnProfile p) {
Intent intent = new Intent(getActivity(), VpnSettings.class); Intent intent = new Intent(getActivity(), VpnSettings.class);
intent.putExtra(VpnSettings.KEY_VPN_PROFILE, (Parcelable) p); intent.putExtra(VpnSettings.KEY_VPN_PROFILE, (Parcelable) p);
setResult(Activity.RESULT_OK, intent); return intent;
} }
private VpnProfileEditor getEditor(VpnProfile p) { private VpnProfileEditor getEditor(VpnProfile p) {

View File

@@ -22,7 +22,6 @@ import com.android.settings.SettingsPreferenceFragment;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.Fragment;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
@@ -39,19 +38,21 @@ import android.net.vpn.VpnState;
import android.net.vpn.VpnType; import android.net.vpn.VpnType;
import android.os.Bundle; import android.os.Bundle;
import android.os.ConditionVariable; import android.os.ConditionVariable;
import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceClickListener;
import android.security.Credentials; import android.security.Credentials;
import android.security.KeyStore; import android.security.KeyStore;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import java.io.File; import java.io.File;
@@ -72,6 +73,9 @@ import java.util.Map;
*/ */
public class VpnSettings extends SettingsPreferenceFragment public class VpnSettings extends SettingsPreferenceFragment
implements DialogInterface.OnClickListener { implements DialogInterface.OnClickListener {
private static final boolean DEBUG = false;
// Key to the field exchanged for profile editing. // Key to the field exchanged for profile editing.
static final String KEY_VPN_PROFILE = "vpn_profile"; static final String KEY_VPN_PROFILE = "vpn_profile";
@@ -87,7 +91,7 @@ public class VpnSettings extends SettingsPreferenceFragment
private static final String PROFILE_OBJ_FILE = ".pobj"; private static final String PROFILE_OBJ_FILE = ".pobj";
private static final int REQUEST_ADD_OR_EDIT_PROFILE = 1; private static final int REQUEST_ADD_OR_EDIT_PROFILE = 1;
private static final int REQUEST_SELECT_VPN_TYPE = 2; static final int REQUEST_SELECT_VPN_TYPE = 2;
private static final int CONTEXT_MENU_CONNECT_ID = ContextMenu.FIRST + 0; private static final int CONTEXT_MENU_CONNECT_ID = ContextMenu.FIRST + 0;
private static final int CONTEXT_MENU_DISCONNECT_ID = ContextMenu.FIRST + 1; private static final int CONTEXT_MENU_DISCONNECT_ID = ContextMenu.FIRST + 1;
@@ -134,6 +138,8 @@ public class VpnSettings extends SettingsPreferenceFragment
private StatusChecker mStatusChecker = new StatusChecker(); private StatusChecker mStatusChecker = new StatusChecker();
private Handler mHandler = new Handler();
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -171,7 +177,8 @@ public class VpnSettings extends SettingsPreferenceFragment
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (DEBUG)
Log.d(TAG, "onResume");
if ((mUnlockAction != null) && isKeyStoreUnlocked()) { if ((mUnlockAction != null) && isKeyStoreUnlocked()) {
Runnable action = mUnlockAction; Runnable action = mUnlockAction;
mUnlockAction = null; mUnlockAction = null;
@@ -282,7 +289,7 @@ public class VpnSettings extends SettingsPreferenceFragment
.setPositiveButton(R.string.vpn_yes_button, .setPositiveButton(R.string.vpn_yes_button,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int w) { public void onClick(DialogInterface dialog, int w) {
startVpnEditor(mActiveProfile); startVpnEditor(mActiveProfile, false);
} }
}) })
.create(); .create();
@@ -295,7 +302,7 @@ public class VpnSettings extends SettingsPreferenceFragment
public void onClick(DialogInterface dialog, int w) { public void onClick(DialogInterface dialog, int w) {
VpnProfile p = mActiveProfile; VpnProfile p = mActiveProfile;
onIdle(); onIdle();
startVpnEditor(p); startVpnEditor(p, false);
} }
}); });
} }
@@ -362,7 +369,7 @@ public class VpnSettings extends SettingsPreferenceFragment
return true; return true;
case CONTEXT_MENU_EDIT_ID: case CONTEXT_MENU_EDIT_ID:
startVpnEditor(p); startVpnEditor(p, false);
return true; return true;
case CONTEXT_MENU_DELETE_ID: case CONTEXT_MENU_DELETE_ID:
@@ -376,14 +383,21 @@ public class VpnSettings extends SettingsPreferenceFragment
@Override @Override
public void onActivityResult(final int requestCode, final int resultCode, public void onActivityResult(final int requestCode, final int resultCode,
final Intent data) { final Intent data) {
if (DEBUG) Log.d(TAG, "onActivityResult , result = " + resultCode + ", data = " + data);
if ((resultCode == Activity.RESULT_CANCELED) || (data == null)) { if ((resultCode == Activity.RESULT_CANCELED) || (data == null)) {
Log.d(TAG, "no result returned by editor"); Log.d(TAG, "no result returned by editor");
return; return;
} }
if (requestCode == REQUEST_SELECT_VPN_TYPE) { if (requestCode == REQUEST_SELECT_VPN_TYPE) {
String typeName = data.getStringExtra(KEY_VPN_TYPE); final String typeName = data.getStringExtra(KEY_VPN_TYPE);
startVpnEditor(createVpnProfile(typeName)); mHandler.post(new Runnable() {
public void run() {
startVpnEditor(createVpnProfile(typeName), true);
}
});
} else if (requestCode == REQUEST_ADD_OR_EDIT_PROFILE) { } else if (requestCode == REQUEST_ADD_OR_EDIT_PROFILE) {
VpnProfile p = data.getParcelableExtra(KEY_VPN_PROFILE); VpnProfile p = data.getParcelableExtra(KEY_VPN_PROFILE);
if (p == null) { if (p == null) {
@@ -400,7 +414,7 @@ public class VpnSettings extends SettingsPreferenceFragment
p.getName()), p.getName()),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int w) { public void onClick(DialogInterface dialog, int w) {
startVpnEditor(profile); startVpnEditor(profile, false);
} }
}); });
return; return;
@@ -431,7 +445,7 @@ public class VpnSettings extends SettingsPreferenceFragment
Util.showErrorMessage(activity, e + ": " + e.getMessage(), Util.showErrorMessage(activity, e + ": " + e.getMessage(),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int w) { public void onClick(DialogInterface dialog, int w) {
startVpnEditor(profile); startVpnEditor(profile, false);
} }
}); });
} }
@@ -615,8 +629,9 @@ public class VpnSettings extends SettingsPreferenceFragment
} }
private void startVpnTypeSelection() { private void startVpnTypeSelection() {
startFragment(this, VpnTypeSelection.class.getCanonicalName(), ((PreferenceActivity)getActivity()).startPreferencePanel(
REQUEST_SELECT_VPN_TYPE, null); VpnTypeSelection.class.getCanonicalName(), null, R.string.vpn_type_title, null,
this, REQUEST_SELECT_VPN_TYPE);
} }
private boolean isKeyStoreUnlocked() { private boolean isKeyStoreUnlocked() {
@@ -666,11 +681,14 @@ public class VpnSettings extends SettingsPreferenceFragment
return false; return false;
} }
private void startVpnEditor(final VpnProfile profile) { private void startVpnEditor(final VpnProfile profile, boolean add) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable(KEY_VPN_PROFILE, profile); args.putParcelable(KEY_VPN_PROFILE, profile);
startFragment(this, VpnEditor.class.getCanonicalName(), // TODO: Show different titles for add and edit.
REQUEST_ADD_OR_EDIT_PROFILE, args); ((PreferenceActivity)getActivity()).startPreferencePanel(
VpnEditor.class.getCanonicalName(), args,
add ? R.string.vpn_details_title : R.string.vpn_details_title, null,
this, REQUEST_ADD_OR_EDIT_PROFILE);
} }
private synchronized void connect(final VpnProfile p) { private synchronized void connect(final VpnProfile p) {

View File

@@ -25,6 +25,7 @@ import android.net.vpn.VpnManager;
import android.net.vpn.VpnType; import android.net.vpn.VpnType;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import java.util.HashMap; import java.util.HashMap;
@@ -46,8 +47,9 @@ public class VpnTypeSelection extends SettingsPreferenceFragment {
@Override @Override
public boolean onPreferenceTreeClick(PreferenceScreen ps, Preference pref) { public boolean onPreferenceTreeClick(PreferenceScreen ps, Preference pref) {
setResult(mTypeMap.get(pref.getTitle().toString())); ((PreferenceActivity)getActivity())
finishFragment(); .finishPreferencePanel(this, Activity.RESULT_OK,
getResultIntent(mTypeMap.get(pref.getTitle().toString())));
return true; return true;
} }
@@ -67,9 +69,9 @@ public class VpnTypeSelection extends SettingsPreferenceFragment {
} }
} }
private void setResult(VpnType type) { private Intent getResultIntent(VpnType type) {
Intent intent = new Intent(getActivity(), VpnSettings.class); Intent intent = new Intent(getActivity(), VpnSettings.class);
intent.putExtra(VpnSettings.KEY_VPN_TYPE, type.toString()); intent.putExtra(VpnSettings.KEY_VPN_TYPE, type.toString());
setResult(Activity.RESULT_OK, intent); return intent;
} }
} }

View File

@@ -67,20 +67,29 @@ public class WifiConfigUiForSetupWizardXL implements WifiConfigUiBase, OnFocusCh
mEdit = edit; mEdit = edit;
mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, false); mView = mInflater.inflate(R.layout.wifi_config_ui_for_setup_wizard, parent, true);
mController = new WifiConfigController(this, mView, mAccessPoint, edit); mController = new WifiConfigController(this, mView, mAccessPoint, edit);
// Set Focus to password View. // Assumes R.id.password is inside security_fields.
final View viewToBeFocused = mView.findViewById(R.id.password); // TODO: confirm it is ok to assume R.id.password is the only EditText to be focused, and
if (viewToBeFocused != null && viewToBeFocused.getVisibility() == View.VISIBLE && // R.id.security_fields is the only parent for possible EditTexts. Possibly we need to
viewToBeFocused instanceof EditText) { // check parentand detect visibility manually.
// After acquiring the focus, we show software keyboard. if (mView.findViewById(R.id.security_fields).getVisibility() == View.VISIBLE) {
viewToBeFocused.setOnFocusChangeListener(this); // Set Focus to password View.
final boolean requestFocusResult = viewToBeFocused.requestFocus(); final View viewToBeFocused = mView.findViewById(R.id.password);
Log.i(TAG, String.format("Focus request %s.", if (viewToBeFocused == null) {
(requestFocusResult ? "successful" : "failed"))); Log.w(TAG, "password field to be focused not found.");
if (!requestFocusResult) { } else if (!(viewToBeFocused instanceof EditText)) {
viewToBeFocused.setOnFocusChangeListener(null); Log.w(TAG, "password field is not EditText");
} else {
// After acquiring the focus, we show software keyboard.
viewToBeFocused.setOnFocusChangeListener(this);
final boolean requestFocusResult = viewToBeFocused.requestFocus();
Log.i(TAG, String.format("Focus request %s.",
(requestFocusResult ? "successful" : "failed")));
if (!requestFocusResult) {
viewToBeFocused.setOnFocusChangeListener(null);
}
} }
} }
} }

View File

@@ -163,6 +163,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
@Override @Override
public void onClick(View view) { public void onClick(View view) {
hideSoftwareKeyboard();
if (view == mAddNetworkButton) { if (view == mAddNetworkButton) {
onAddNetworkButtonPressed(); onAddNetworkButtonPressed();
} else if (view == mRefreshButton) { } else if (view == mRefreshButton) {
@@ -184,7 +185,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
} else if (view == mDetailButton) { } else if (view == mDetailButton) {
mWifiSettings.showDialogForSelectedPreference(); mWifiSettings.showDialogForSelectedPreference();
} }
hideSoftwareKeyboard();
} }
private void hideSoftwareKeyboard() { private void hideSoftwareKeyboard() {
@@ -334,7 +334,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
} else { } else {
view.findViewById(R.id.wifi_general_info).setVisibility(View.GONE); view.findViewById(R.id.wifi_general_info).setVisibility(View.GONE);
} }
parent.addView(view); // parent.addView(view);
mStatusText.setText(R.string.wifi_setup_status_edit_network); mStatusText.setText(R.string.wifi_setup_status_edit_network);
mAddNetworkButton.setVisibility(View.GONE); mAddNetworkButton.setVisibility(View.GONE);