Commit d3669928 authored by Daisuke Miyakawa's avatar Daisuke Miyakawa

Add Wifi Setup screen for Setup Wizard with XL size screen.

* Add WifiSettingsForSetupWizardXL as a new Activity
The activity has WifiSettings fragment in it. It also contains
several buttons, texts around the fragment.

* Making configuration UI part of Preference list.
In Wifi Setup for Setup Wizard XL, WifiSettings fragment lets
a UI for configuring access points shown inside a
PregerenceCategory object, while it has been shown as Dialog.

To achieve this action, WifiDialog is decomposed into two parts:
- WifiConfigUiBase (Mainly UI part)
- WifiConfigController (Mainly Wifi controller part)

All codes for wifi configuration in WifiDialog is now in
WifiConfigController, which is reused from
WifiConfigPreference.

* Misc stuff
- Remove AccessPoint#compareTo(). Instead,
  AccessPoint.AccessPointComparater should be used when needed.

Change-Id: I520d690d3301837d32f91dad54a973a379ce1989
parent 0b4dc9fd
......@@ -99,6 +99,11 @@
</intent-filter>
</activity-alias>
<activity android:name=".wifi.WifiSettingsForSetupWizardXL"
android:clearTaskOnLaunch="true"
android:screenOrientation="landscape"
android:exported="true" />
<activity android:name=".wifi.AdvancedSettings"
android:label="@string/wifi_ip_settings_titlebar"
>
......
......@@ -3,4 +3,4 @@
-keep class com.android.settings.*Picker
-keep class com.android.settings.*Settings
-keep class com.android.settings.wifi.*Settings
-keep class com.android.settings.deviceinfo.*
-keep class com.android.settings.deviceinfo.*
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize">
<LinearLayout android:id="@+android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="70dip"
android:paddingBottom="80dip"
android:paddingLeft="60dip"
android:paddingRight="60dip">
<!-- Left: almost empty with one title at the top -->
<RelativeLayout
android:orientation="vertical"
android:layout_width="0px"
android:layout_weight=".3"
android:layout_height="fill_parent"
android:paddingRight="10dip"
android:paddingBottom="10dip">
<TextView
android:id="@+id/wifi_setup_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:textSize="48dip"
android:textColor="#FF30FF30"
android:text="@string/wifi_setup_title"/>
<Button
android:id="@+id/wifi_setup_cancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:textSize="24dip"
android:text="@string/wifi_cancel"
android:visibility="gone" />
</RelativeLayout>
<!-- Center: Full of fragment -->
<LinearLayout
android:orientation="vertical"
android:layout_width="0px"
android:layout_weight=".4"
android:layout_height="fill_parent"
android:paddingTop="20dip"
android:paddingLeft="10dip"
android:paddingRight="30dip"
android:paddingBottom="15dip">
<!-- Assume the text size of this text should be same as Preference's
texts. See also preference.xml -->
<TextView
android:id="@+id/wifi_setup_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff113344"
android:paddingLeft="5dip"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:layout_marginBottom="20dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/wifi_setup_status_select_network"/>
<fragment
class="com.android.settings.wifi.WifiSettings"
android:id="@+id/wifi_setup_fragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- Right: various information -->
<RelativeLayout
android:orientation="vertical"
android:layout_width="0px"
android:layout_weight=".3"
android:layout_height="fill_parent"
android:paddingTop="22dip"
android:paddingLeft="30dip"
android:paddingBottom="10dip">
<TextView
android:id="@+id/scanning_progress_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textSize="24dip"
android:text="@string/progress_scanning"/>
<ProgressBar
android:id="@+id/scanning_progress_bar"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_below="@id/scanning_progress_text"
style="?android:attr/progressBarStyleHorizontal" />
<Button
android:id="@+id/wifi_setup_connect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:textSize="24dip"
android:text="@string/wifi_connect"
android:visibility="gone" />
<Button
android:id="@+id/wifi_setup_forget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:textSize="24dip"
android:text="@string/wifi_forget"
android:visibility="gone" />
<Button
android:id="@+id/wifi_setup_skip_or_next"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_alignParentBottom="true"
android:textSize="24dip"
android:text="@string/wifi_setup_skip" />
<Button
android:id="@+id/wifi_setup_refresh_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/wifi_setup_skip_or_next"
android:textSize="24dip"
android:text="@string/wifi_setup_refresh_list" />
<Button
android:id="@+id/wifi_setup_add_network"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/wifi_setup_refresh_list"
android:textSize="24dip"
android:text="@string/wifi_setup_add_network" />
</RelativeLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- All ids in this layout must be in wifi_dialog.xml -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- <TextView android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/title" /> -->
<LinearLayout android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
<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" -->
<LinearLayout android:id="@+id/fields"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<LinearLayout android:id="@+id/eap"
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_eap_method" />
<Spinner android:id="@+id/method"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/wifi_eap_method"
android:entries="@array/wifi_eap_method" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/please_select_phase2" />
<Spinner android:id="@+id/phase2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/please_select_phase2"
android:entries="@array/wifi_phase2_entries" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_eap_ca_cert" />
<Spinner android:id="@+id/ca_cert"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/wifi_eap_ca_cert" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_eap_user_cert" />
<Spinner android:id="@+id/user_cert"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/wifi_eap_user_cert" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_eap_identity" />
<EditText android:id="@+id/identity"
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_eap_anonymous" />
<EditText android:id="@+id/anonymous"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="textNoSuggestions" />
</LinearLayout> <!-- android:id="@+id/eap" -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_password" />
<EditText android:id="@+id/password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:password="true" />
<CheckBox android:id="@+id/show_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_show_password" />
</LinearLayout> <!-- android:id="@+id/fields" -->
</LinearLayout>
......@@ -2644,4 +2644,42 @@ found in the list of installed applications.</string>
<string name="sound_category_calls_title">Incoming calls</string>
<string name="sound_category_notification_title">Notifications</string>
<string name="sound_category_feedback_title">Feedback</string>
<!-- Wifi Setup For Setup Wizard with XL screen -->
<!-- Title shown in Wifi Setup For Setup Wizard with XL screen -->
<string name="wifi_setup_title">WiFi setup</string>
<!-- Text message shown when Wifi is not connected.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_not_connected">Not connected</string>
<!-- Button message shown on the button adding manual setting.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_add_network">Add network</string>
<!-- Button message shown on the button refreshing a list of network.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_refresh_list">Refresh list</string>
<!-- Button message shown on the button enabling users skip Wifi Setup.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_skip">Skip</string>
<!-- Button message shown on the button enabling users go the next step.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_next">Next</string>
<!-- Message shown above available network when there's no connected network.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_status_select_network">Touch to select network</string>
<!-- Message shown above available networks when a user clicked one of available
networks and the UI is showing one possible existing network.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_status_existing_network">Connect to existing network</string>
<!-- The message shown above available networks when a user clicked "Add network"
button. Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_status_new_network">Connect to new network</string>
<!-- The message shown above available networks when a user clicked one of available
networks or created another profile and he/she is waiting for the connection
is established.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_status_connecting">Connecting...</string>
<!-- The message show above available networks when connection is established.
Used in Wifi Setup For Setup Wizard with XL screen. -->
<string name="wifi_setup_status_connected">Connected</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<com.android.settings.wifi.AccessPointCategoryForSetupWizardXL
android:key="access_points"
android:persistent="false" />
</PreferenceScreen>
......@@ -21,9 +21,7 @@ import android.preference.PreferenceCategory;
import android.util.AttributeSet;
import android.view.View;
import java.util.Map;
public class ProgressCategory extends PreferenceCategory {
public class ProgressCategory extends ProgressCategoryBase {
private boolean mProgress = false;
private View oldView = null;
......@@ -36,10 +34,10 @@ public class ProgressCategory extends PreferenceCategory {
@Override
public void onBindView(View view) {
super.onBindView(view);
View textView = view.findViewById(R.id.scanning_text);
View progressBar = view.findViewById(R.id.scanning_progress);
final View textView = view.findViewById(R.id.scanning_text);
final View progressBar = view.findViewById(R.id.scanning_progress);
int visibility = mProgress ? View.VISIBLE : View.INVISIBLE;
final int visibility = mProgress ? View.VISIBLE : View.INVISIBLE;
textView.setVisibility(visibility);
progressBar.setVisibility(visibility);
......@@ -50,11 +48,8 @@ public class ProgressCategory extends PreferenceCategory {
}
oldView = view;
}
/**
* Turn on/off the progress indicator and text on the right.
* @param progressOn whether or not the progress should be displayed
*/
@Override
public void setProgress(boolean progressOn) {
mProgress = progressOn;
notifyChanged();
......
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings;
import android.content.Context;
import android.preference.PreferenceCategory;
import android.util.AttributeSet;
public abstract class ProgressCategoryBase extends PreferenceCategory {
public ProgressCategoryBase(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Turn on/off the progress indicator and text on the right.
* @param progressOn whether or not the progress should be displayed
*/
public abstract void setProgress(boolean progressOn);
}
\ No newline at end of file
......@@ -16,24 +16,53 @@
package com.android.settings.wifi;
import com.android.settings.R;
import android.content.Context;
import android.net.NetworkInfo.DetailedState;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.ScanResult;
import android.preference.Preference;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import com.android.settings.R;
import java.util.Comparator;
class AccessPoint extends Preference {
private static final int[] STATE_SECURED = {R.attr.state_encrypted};
private static final int[] STATE_NONE = {};
public static final class Comparater
implements Comparator<AccessPoint> {
@Override
public int compare(AccessPoint accessPoint1, AccessPoint accessPoint2) {
// Active one goes first.
if (accessPoint1.mInfo != accessPoint2.mInfo) {
return (accessPoint1.mInfo != null) ? -1 : 1;
}
// Reachable one goes before unreachable one.
if ((accessPoint1.mRssi ^ accessPoint2.mRssi) < 0) {
return (accessPoint1.mRssi != Integer.MAX_VALUE) ? -1 : 1;
}
// Configured one goes before unconfigured one.
if ((accessPoint1.networkId ^ accessPoint2.networkId) < 0) {
return (accessPoint1.networkId != -1) ? -1 : 1;
}
// Sort by signal strength.
int difference = WifiManager.compareSignalLevel(
accessPoint2.mRssi, accessPoint1.mRssi);
if (difference != 0) {
return difference;
}
// Sort by ssid.
return accessPoint1.ssid.compareToIgnoreCase(accessPoint2.ssid);
}
}
static final int SECURITY_NONE = 0;
static final int SECURITY_WEP = 1;
static final int SECURITY_PSK = 2;
......@@ -105,32 +134,6 @@ class AccessPoint extends Preference {
super.onBindView(view);
}
@Override
public int compareTo(Preference preference) {
if (!(preference instanceof AccessPoint)) {
return 1;
}
AccessPoint other = (AccessPoint) preference;
// Active one goes first.
if (mInfo != other.mInfo) {
return (mInfo != null) ? -1 : 1;
}
// Reachable one goes before unreachable one.
if ((mRssi ^ other.mRssi) < 0) {
return (mRssi != Integer.MAX_VALUE) ? -1 : 1;
}
// Configured one goes before unconfigured one.
if ((networkId ^ other.networkId) < 0) {
return (networkId != -1) ? -1 : 1;
}
// Sort by signal strength.
int difference = WifiManager.compareSignalLevel(other.mRssi, mRssi);
if (difference != 0) {
return difference;
}
// Sort by ssid.
return ssid.compareToIgnoreCase(other.ssid);
}
boolean update(ScanResult result) {
// We do not call refresh() since this is called before onBindView().
......
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.wifi;
import android.content.Context;
import android.util.AttributeSet;
import com.android.settings.ProgressCategoryBase;
import com.android.settings.R;
public class AccessPointCategoryForSetupWizardXL extends ProgressCategoryBase {
public AccessPointCategoryForSetupWizardXL(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.access_point_category_for_setup_wizard_xl);
}
@Override
public void setProgress(boolean progressOn) {
notifyChanged();
}
}
\ No newline at end of file
......@@ -16,11 +16,10 @@
package com.android.settings.wifi;
import com.android.settings.R;
import android.content.Context;
import android.net.NetworkInfo.DetailedState;
import android.text.TextUtils;
import com.android.settings.R;
class Summary {
static String get(Context context, String ssid, DetailedState state) {
......
This diff is collapsed.
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.wifi;
import android.content.Context;
import android.content.DialogInterface;
import android.preference.Preference;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.android.settings.R;
/**
* Preference letting users modify a setting for Wifi network. This work as an alternative UI
* for {@link WifiDialog} without shouwing popup Dialog.
*/
public class WifiConfigPreference extends Preference implements WifiConfigUiBase {
private WifiSettings mWifiSettings;
private View mView;
private final DialogInterface.OnClickListener mListener;
private WifiConfigController mController;
private AccessPoint mAccessPoint;
private boolean mEdit;
private LayoutInflater mInflater;
public WifiConfigPreference(WifiSettings wifiSettings,
DialogInterface.OnClickListener listener,
AccessPoint accessPoint, boolean edit) {
super(wifiSettings.getActivity());
mWifiSettings = wifiSettings;
setLayoutResource(R.layout.wifi_config_preference);
mListener = listener;
mAccessPoint = accessPoint;
mEdit = edit;
mInflater = (LayoutInflater)
wifiSettings.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
protected View onCreateView(ViewGroup parent) {
// Called every time the list is created.
if (mView != null) {
// TODO: we need to re-forcus something.
return mView;
}
mView = mInflater.inflate(getLayoutResource(), parent, false);
mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mListener);
return mView;
}
@Override
public WifiConfigController getController() {