Fix UI for WifiSettings for XL screen
Change-Id: I874e1e8d86e8b219414f6bf2ff945ea4f9ab7a6c
This commit is contained in:
@@ -93,12 +93,6 @@
|
|||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentBottom="true">
|
android:layout_alignParentBottom="true">
|
||||||
|
|
||||||
<Button android:id="@+id/wifi_setup_connect"
|
|
||||||
android:layout_width="260dip"
|
|
||||||
android:layout_height="60dip"
|
|
||||||
android:textSize="24dip"
|
|
||||||
android:text="@string/wifi_connect"
|
|
||||||
android:visibility="gone" />
|
|
||||||
<Button android:id="@+id/wifi_setup_forget"
|
<Button android:id="@+id/wifi_setup_forget"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
@@ -106,6 +100,14 @@
|
|||||||
android:text="@string/wifi_forget"
|
android:text="@string/wifi_forget"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<Button android:id="@+id/wifi_setup_connect"
|
||||||
|
android:layout_width="260dip"
|
||||||
|
android:layout_height="60dip"
|
||||||
|
android:layout_marginTop="20dip"
|
||||||
|
android:textSize="24dip"
|
||||||
|
android:text="@string/wifi_connect"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button android:id="@+id/wifi_setup_add_network"
|
<Button android:id="@+id/wifi_setup_add_network"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
@@ -134,7 +136,6 @@
|
|||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
android:layout_above="@+id/wifi_setup_cancel"
|
android:layout_above="@+id/wifi_setup_cancel"
|
||||||
android:layout_alignLeft="@+id/wifi_setup_cancel"
|
android:layout_alignLeft="@+id/wifi_setup_cancel"
|
||||||
android:layout_marginBottom="30dip"
|
|
||||||
android:textSize="24dip"
|
android:textSize="24dip"
|
||||||
android:text="@string/wifi_detail"
|
android:text="@string/wifi_detail"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
@@ -142,6 +143,7 @@
|
|||||||
<Button android:id="@+id/wifi_setup_cancel"
|
<Button android:id="@+id/wifi_setup_cancel"
|
||||||
android:layout_width="260dip"
|
android:layout_width="260dip"
|
||||||
android:layout_height="60dip"
|
android:layout_height="60dip"
|
||||||
|
android:layout_marginTop="20dip"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_toLeftOf="@id/right_buttons"
|
android:layout_toLeftOf="@id/right_buttons"
|
||||||
android:textSize="24dip"
|
android:textSize="24dip"
|
||||||
|
@@ -56,7 +56,32 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/wifi_show_password" />
|
android:text="@string/wifi_show_password" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<LinearLayout android:id="@+id/type"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_ssid" />
|
||||||
|
|
||||||
|
<EditText android:id="@+id/ssid"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:inputType="textNoSuggestions" />
|
||||||
|
|
||||||
|
<TextView android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi_security" />
|
||||||
|
|
||||||
|
<Spinner android:id="@+id/security"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:prompt="@string/wifi_security"
|
||||||
|
android:entries="@array/wifi_security" />
|
||||||
|
</LinearLayout> <!-- android:id="@+id/type" -->
|
||||||
|
|
||||||
<!-- All the views below are "gone".
|
<!-- All the views below are "gone".
|
||||||
We want them as data storage, not as UI components. -->
|
We want them as data storage, not as UI components. -->
|
||||||
@@ -109,33 +134,6 @@
|
|||||||
android:inputType="textPassword" />
|
android:inputType="textPassword" />
|
||||||
</LinearLayout> -->
|
</LinearLayout> -->
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/type"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<TextView android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/wifi_ssid" />
|
|
||||||
|
|
||||||
<EditText android:id="@+id/ssid"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:inputType="textNoSuggestions" />
|
|
||||||
|
|
||||||
<TextView android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/wifi_security" />
|
|
||||||
|
|
||||||
<Spinner android:id="@+id/security"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:prompt="@string/wifi_security"
|
|
||||||
android:entries="@array/wifi_security" />
|
|
||||||
</LinearLayout> <!-- android:id="@+id/type" -->
|
|
||||||
|
|
||||||
<!-- android:id="@+id/security_fields" -->
|
<!-- android:id="@+id/security_fields" -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@@ -21,16 +21,21 @@ import com.android.settings.R;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference letting users modify a setting for Wifi network. This work as an alternative UI
|
* Preference letting users modify a setting for Wifi network. This work as an alternative UI
|
||||||
* for {@link WifiDialog} without shouwing popup Dialog.
|
* for {@link WifiDialog} without shouwing popup Dialog.
|
||||||
*/
|
*/
|
||||||
public class WifiConfigPreference extends Preference implements WifiConfigUiBase {
|
public class WifiConfigPreference extends Preference implements WifiConfigUiBase {
|
||||||
|
private static final String TAG = "WifiConfigPreference";
|
||||||
|
|
||||||
private WifiSettings mWifiSettings;
|
private WifiSettings mWifiSettings;
|
||||||
private View mView;
|
private View mView;
|
||||||
private final DialogInterface.OnClickListener mListener;
|
private final DialogInterface.OnClickListener mListener;
|
||||||
@@ -38,6 +43,9 @@ public class WifiConfigPreference extends Preference implements WifiConfigUiBase
|
|||||||
private AccessPoint mAccessPoint;
|
private AccessPoint mAccessPoint;
|
||||||
private boolean mEdit;
|
private boolean mEdit;
|
||||||
|
|
||||||
|
// Stores an View id to be focused. Used when view isn't available while setFocus() is called.
|
||||||
|
private int mFocusId = -1;
|
||||||
|
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
public WifiConfigPreference(WifiSettings wifiSettings,
|
public WifiConfigPreference(WifiSettings wifiSettings,
|
||||||
@@ -57,12 +65,16 @@ public class WifiConfigPreference extends Preference implements WifiConfigUiBase
|
|||||||
@Override
|
@Override
|
||||||
protected View onCreateView(ViewGroup parent) {
|
protected View onCreateView(ViewGroup parent) {
|
||||||
// Called every time the list is created.
|
// Called every time the list is created.
|
||||||
if (mView != null) {
|
if (mView == null) {
|
||||||
// TODO: we need to re-forcus something.
|
|
||||||
return mView;
|
|
||||||
}
|
|
||||||
mView = mInflater.inflate(getLayoutResource(), parent, false);
|
mView = mInflater.inflate(getLayoutResource(), parent, false);
|
||||||
mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mListener);
|
mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mFocusId >= 0) {
|
||||||
|
trySetFocusAndLaunchSoftInput(mFocusId);
|
||||||
|
mFocusId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +83,31 @@ public class WifiConfigPreference extends Preference implements WifiConfigUiBase
|
|||||||
return mController;
|
return mController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFocus(int id) {
|
||||||
|
if (mView != null) {
|
||||||
|
trySetFocusAndLaunchSoftInput(id);
|
||||||
|
mFocusId = -1;
|
||||||
|
} else {
|
||||||
|
mFocusId = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void trySetFocusAndLaunchSoftInput(int id) {
|
||||||
|
final View viewToBeFocused = mView.findViewById(id);
|
||||||
|
if (viewToBeFocused != null && viewToBeFocused.getVisibility() == View.VISIBLE) {
|
||||||
|
viewToBeFocused.requestFocus();
|
||||||
|
// TODO: doesn't work.
|
||||||
|
if (viewToBeFocused instanceof EditText) {
|
||||||
|
Log.d(TAG, "Focused View is EditText. We try showing the software keyboard");
|
||||||
|
// viewToBeFocused.performClick();
|
||||||
|
final InputMethodManager inputMethodManager =
|
||||||
|
(InputMethodManager)
|
||||||
|
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
inputMethodManager.showSoftInput(viewToBeFocused, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public View findViewById(int id) {
|
public View findViewById(int id) {
|
||||||
return mView.findViewById(id);
|
return mView.findViewById(id);
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,6 @@ import android.preference.PreferenceScreen;
|
|||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
import android.security.Credentials;
|
import android.security.Credentials;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -639,6 +638,10 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
forget();
|
forget();
|
||||||
} else if (button == WifiDialog.BUTTON_SUBMIT) {
|
} else if (button == WifiDialog.BUTTON_SUBMIT) {
|
||||||
submit();
|
submit();
|
||||||
|
final Activity activity = getActivity();
|
||||||
|
if (activity instanceof WifiSettingsForSetupWizardXL) {
|
||||||
|
((WifiSettingsForSetupWizardXL)activity).onConnectButtonPressed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,6 +743,11 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
/* package */ void onAddNetworkPressed() {
|
/* package */ void onAddNetworkPressed() {
|
||||||
mSelectedAccessPoint = null;
|
mSelectedAccessPoint = null;
|
||||||
showConfigUi(null, true);
|
showConfigUi(null, true);
|
||||||
|
|
||||||
|
// Set focus to the EditText the user needs to configure.
|
||||||
|
if (mConfigPreference != null) {
|
||||||
|
mConfigPreference.setFocus(R.id.ssid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ int getAccessPointsCount() {
|
/* package */ int getAccessPointsCount() {
|
||||||
|
@@ -23,6 +23,7 @@ import android.content.Context;
|
|||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@@ -129,14 +130,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
break;
|
break;
|
||||||
case R.id.wifi_setup_connect:
|
case R.id.wifi_setup_connect:
|
||||||
mWifiSettings.submit();
|
mWifiSettings.submit();
|
||||||
|
onConnectButtonPressed();
|
||||||
// updateConnectionState() isn't called soon after the user's "connect" action,
|
|
||||||
// and the user still sees "not connected" message for a while, which looks strange.
|
|
||||||
// We instead manually show "connecting" message before the system gets actual
|
|
||||||
// "connecting" message from Wi-Fi module.
|
|
||||||
showConnectingStatus();
|
|
||||||
mShowingConnectingMessageManually = true;
|
|
||||||
mIgnoringWifiNotificationCount = 2;
|
|
||||||
break;
|
break;
|
||||||
case R.id.wifi_setup_forget:
|
case R.id.wifi_setup_forget:
|
||||||
mWifiSettings.forget();
|
mWifiSettings.forget();
|
||||||
@@ -186,7 +180,10 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
mProgressBar.setProgress(2);
|
mProgressBar.setProgress(2);
|
||||||
mProgressText.setText(Summary.get(this, state));
|
mProgressText.setText(Summary.get(this, state));
|
||||||
mStatusText.setText(R.string.wifi_setup_status_proceed_to_next);
|
mStatusText.setText(R.string.wifi_setup_status_proceed_to_next);
|
||||||
enableButtons();
|
// We don't want "Add network" button here. User can press it after pressing
|
||||||
|
// "Refresh" button.
|
||||||
|
((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(true);
|
||||||
|
((Button)findViewById(R.id.wifi_setup_skip_or_next)).setEnabled(true);
|
||||||
|
|
||||||
if (mIgnoringWifiNotificationCount > 0) {
|
if (mIgnoringWifiNotificationCount > 0) {
|
||||||
// The network is already available before doing anything. We avoid skip this
|
// The network is already available before doing anything. We avoid skip this
|
||||||
@@ -219,7 +216,6 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
mShowingConnectingMessageManually = false;
|
mShowingConnectingMessageManually = false;
|
||||||
mProgressBar.setIndeterminate(false);
|
mProgressBar.setIndeterminate(false);
|
||||||
mProgressBar.setProgress(0);
|
mProgressBar.setProgress(0);
|
||||||
mStatusText.setText(R.string.wifi_setup_status_select_network);
|
|
||||||
mProgressText.setText(getString(R.string.wifi_setup_not_connected));
|
mProgressText.setText(getString(R.string.wifi_setup_not_connected));
|
||||||
enableButtons();
|
enableButtons();
|
||||||
}
|
}
|
||||||
@@ -254,7 +250,21 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
|||||||
public void onRefreshAccessPoints() {
|
public void onRefreshAccessPoints() {
|
||||||
mIgnoringWifiNotificationCount = 5;
|
mIgnoringWifiNotificationCount = 5;
|
||||||
mProgressBar.setIndeterminate(true);
|
mProgressBar.setIndeterminate(true);
|
||||||
|
((Button)findViewById(R.id.wifi_setup_add_network)).setEnabled(false);
|
||||||
|
((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(false);
|
||||||
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
||||||
mStatusText.setText(R.string.wifi_setup_status_scanning);
|
mStatusText.setText(R.string.wifi_setup_status_scanning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* package */ void onConnectButtonPressed() {
|
||||||
|
// updateConnectionState() isn't called soon after the user's "connect" action,
|
||||||
|
// and the user still sees "not connected" message for a while, which looks strange.
|
||||||
|
// We instead manually show "connecting" message before the system gets actual
|
||||||
|
// "connecting" message from Wi-Fi module.
|
||||||
|
showConnectingStatus();
|
||||||
|
((Button)findViewById(R.id.wifi_setup_add_network)).setEnabled(false);
|
||||||
|
((Button)findViewById(R.id.wifi_setup_refresh_list)).setEnabled(false);
|
||||||
|
mShowingConnectingMessageManually = true;
|
||||||
|
mIgnoringWifiNotificationCount = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user