[WifiSettings] Submit Wi-Fi dialog with enter key

Add a OnKeyListener for hardware keyboards and an
OnEditorActionListener for on-screen IMEs to submit the Wi-Fi dialog
with the currently entered information.

Before committing the action, check for whether the dialog is
submittable -- that is checking whether all necessary information has
been entered. If not the enter key behaves the same as it is before
the change.

Bug: 22211604
Change-Id: Idede4233a7385d3bcd8fd6614948270280536bf1
This commit is contained in:
Maurice Lam
2015-08-27 16:06:55 -07:00
parent e3be8eb3e5
commit 2662df8433
5 changed files with 95 additions and 40 deletions

View File

@@ -18,7 +18,6 @@ package com.android.settings.wifi;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.net.wifi.WifiManager;
import android.os.Bundle;
@@ -45,7 +44,7 @@ import java.util.List;
* UI to manage saved networks/access points.
*/
public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
implements DialogInterface.OnClickListener, Indexable {
implements Indexable, WifiDialog.WifiDialogListener {
private static final String TAG = "SavedAccessPointsWifiSettings";
private WifiDialog mDialog;
@@ -170,14 +169,19 @@ public class SavedAccessPointsWifiSettings extends SettingsPreferenceFragment
}
@Override
public void onClick(DialogInterface dialogInterface, int button) {
if (button == WifiDialog.BUTTON_FORGET && mSelectedAccessPoint != null) {
public void onForget(WifiDialog dialog) {
if (mSelectedAccessPoint != null) {
mWifiManager.forget(mSelectedAccessPoint.getConfig().networkId, null);
getPreferenceScreen().removePreference((Preference) mSelectedAccessPoint.getTag());
mSelectedAccessPoint = null;
}
}
@Override
public void onSubmit(WifiDialog dialog) {
// Ignored
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
if (preference instanceof AccessPointPreference) {