Modify implementation around SetupWizard XL
Bug: 3005211 Change-Id: Ia01957725956d570370aceeab01750d77069001a
This commit is contained in:
@@ -27,19 +27,21 @@
|
||||
android:layout_width="0px"
|
||||
android:layout_weight=".3"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingRight="10dip"
|
||||
android:paddingRight="50dip"
|
||||
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:layout_alignParentRight="true"
|
||||
android:gravity="right"
|
||||
android:textSize="48dip"
|
||||
android:textColor="#FF30FF30"
|
||||
android:textColor="#FFC5DF28"
|
||||
android:text="@string/wifi_setup_title"/>
|
||||
<Button android:id="@+id/wifi_setup_cancel"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="220dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textSize="24dip"
|
||||
android:text="@string/wifi_cancel"
|
||||
android:visibility="gone" />
|
||||
@@ -51,15 +53,15 @@
|
||||
android:layout_weight=".4"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingTop="20dip"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingRight="30dip"
|
||||
android:paddingLeft="50dip"
|
||||
android:paddingRight="50dip"
|
||||
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:background="#ff555555"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingTop="5dip"
|
||||
android:paddingBottom="5dip"
|
||||
@@ -78,29 +80,28 @@
|
||||
android:layout_weight=".3"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingTop="22dip"
|
||||
android:paddingLeft="30dip"
|
||||
android:paddingLeft="50dip"
|
||||
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"/>
|
||||
android:textSize="24dip"/>
|
||||
<ProgressBar android:id="@+id/scanning_progress_bar"
|
||||
android:layout_width="100dip"
|
||||
android:layout_width="220dip"
|
||||
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_width="220dip"
|
||||
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_width="220dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:textSize="24dip"
|
||||
@@ -108,7 +109,7 @@
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button android:id="@+id/wifi_setup_skip_or_next"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="220dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dip"
|
||||
android:layout_alignParentBottom="true"
|
||||
@@ -116,14 +117,14 @@
|
||||
android:text="@string/wifi_setup_skip" />
|
||||
|
||||
<Button android:id="@+id/wifi_setup_refresh_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_width="220dip"
|
||||
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_width="220dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/wifi_setup_refresh_list"
|
||||
android:textSize="24dip"
|
||||
|
@@ -2702,8 +2702,12 @@ found in the list of installed applications.</string>
|
||||
<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. -->
|
||||
Used in Wifi Setup. -->
|
||||
<string name="wifi_setup_status_existing_network">Connect to existing network</string>
|
||||
<!-- Message shown above available networks when a user clicked one of available
|
||||
networks and the UI is prompting the user to edit the network configuration
|
||||
if needed. Used in Wifi Setup with XL screen. [CHAR LIMIT=35] -->
|
||||
<string name="wifi_setup_status_edit_network">Enter network configuration</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>
|
||||
|
@@ -87,6 +87,12 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
// Note: this is only effective in Setup Wizard with XL screen size.
|
||||
private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
|
||||
|
||||
// In SetupWizard XL, We limit the number of showable access points so that the
|
||||
// ListView won't become larger than the screen.
|
||||
//
|
||||
// This constant doesn't affect other contexts other than SetupWizard XL.
|
||||
private static int MAX_MENU_COUNT_IN_XL = 7;
|
||||
|
||||
private final IntentFilter mFilter;
|
||||
private final BroadcastReceiver mReceiver;
|
||||
private final Scanner mScanner;
|
||||
@@ -113,6 +119,10 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
private WifiConfigPreference mConfigPreference;
|
||||
private WifiDialog mDialog;
|
||||
|
||||
// Used only in SetupWizard XL, which remembers the network a user selected and
|
||||
// refrain other available networks when trying to connect it.
|
||||
private AccessPoint mConnectingAccessPoint;
|
||||
|
||||
private boolean mRefrainListUpdate;
|
||||
|
||||
public WifiSettings() {
|
||||
@@ -370,7 +380,10 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
|
||||
mConfigPreference = new WifiConfigPreference(this, this, accessPoint, edit);
|
||||
toggleButtonsVisibility(false);
|
||||
|
||||
final Activity activity = getActivity();
|
||||
if (activity instanceof WifiSettingsForSetupWizardXL) {
|
||||
((WifiSettingsForSetupWizardXL)activity).onWifiConfigPreferenceAttached(edit);
|
||||
}
|
||||
updateAccessPoints();
|
||||
mScanner.pause();
|
||||
}
|
||||
@@ -422,8 +435,10 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
if (mConfigPreference != null) {
|
||||
mAccessPoints.removeAll();
|
||||
if (mConnectingAccessPoint != null) {
|
||||
mAccessPoints.addPreference(mConnectingAccessPoint);
|
||||
} else if (mConfigPreference != null) {
|
||||
final AccessPoint parent = mConfigPreference.getAccessPoint();
|
||||
if (parent != null) {
|
||||
parent.setSelectable(false);
|
||||
@@ -433,9 +448,14 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
} else {
|
||||
// AccessPoints are automatically sorted with TreeSet.
|
||||
final Collection<AccessPoint> accessPoints = constructAccessPoints();
|
||||
mAccessPoints.removeAll();
|
||||
|
||||
int count = MAX_MENU_COUNT_IN_XL;
|
||||
for (AccessPoint accessPoint : accessPoints) {
|
||||
mAccessPoints.addPreference(accessPoint);
|
||||
count--;
|
||||
if (count <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -520,7 +540,8 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
// Maybe there's a WifiConfigPreference
|
||||
Preference preference = mAccessPoints.getPreference(i);
|
||||
if (preference instanceof AccessPoint) {
|
||||
((AccessPoint) preference).update(mLastInfo, mLastState);
|
||||
final AccessPoint accessPoint = (AccessPoint) preference;
|
||||
accessPoint.update(mLastInfo, mLastState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,6 +655,11 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
break;
|
||||
}
|
||||
|
||||
if (mInXlSetupWizard && mConfigPreference != null) {
|
||||
mConnectingAccessPoint = mSelectedAccessPoint;
|
||||
mConnectingAccessPoint.setSelectable(false);
|
||||
}
|
||||
|
||||
detachConfigPreference();
|
||||
}
|
||||
|
||||
@@ -656,6 +682,7 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
mConfigPreference = null;
|
||||
mConnectingAccessPoint = null;
|
||||
mAccessPoints.removeAll();
|
||||
|
||||
final Activity activity = getActivity();
|
||||
|
@@ -56,6 +56,13 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
||||
private WifiSettings mWifiSettings;
|
||||
private TextView mStatusText;
|
||||
|
||||
// This count reduces every time when there's a notification about WiFi status change.
|
||||
// During the term this is >0, The system shows the message "connecting", regardless
|
||||
// of the actual WiFi status. After this count's becoming 0, the status message correctly
|
||||
// reflects what WiFi Picker told it. This is a tweak for letting users not confused
|
||||
// with instable WiFi state during the first scan.
|
||||
private int mIgnoringWifiNotificationCount = 5;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -70,6 +77,7 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
||||
|
||||
public void setup() {
|
||||
mProgressText = (TextView)findViewById(R.id.scanning_progress_text);
|
||||
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
||||
mProgressBar = (ProgressBar)findViewById(R.id.scanning_progress_bar);
|
||||
mProgressBar.setMax(2);
|
||||
mProgressBar.setIndeterminate(true);
|
||||
@@ -104,11 +112,13 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
||||
mWifiSettings.forget();
|
||||
break;
|
||||
case R.id.wifi_setup_cancel:
|
||||
mStatusText.setText(R.string.wifi_setup_status_select_network);
|
||||
mWifiSettings.detachConfigPreference();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Called from WifiSettings
|
||||
public void updateConnectionState(DetailedState originalState) {
|
||||
final DetailedState state = stateMap.get(originalState);
|
||||
switch (state) {
|
||||
@@ -136,23 +146,29 @@ public class WifiSettingsForSetupWizardXL extends Activity implements OnClickLis
|
||||
mProgressBar.setProgress(2);
|
||||
mStatusText.setText(R.string.wifi_setup_status_connected);
|
||||
mProgressText.setText(Summary.get(this, state));
|
||||
setResult(Activity.RESULT_OK);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
default: // Not connected.
|
||||
if (mWifiSettings.getAccessPointsCount() == 0 &&
|
||||
mIgnoringWifiNotificationCount > 0) {
|
||||
mIgnoringWifiNotificationCount--;
|
||||
mProgressBar.setIndeterminate(true);
|
||||
mProgressText.setText(Summary.get(this, DetailedState.SCANNING));
|
||||
return;
|
||||
} else {
|
||||
mProgressBar.setIndeterminate(false);
|
||||
mProgressBar.setProgress(0);
|
||||
mStatusText.setText(R.string.wifi_setup_status_select_network);
|
||||
mProgressText.setText(getString(R.string.wifi_setup_not_connected));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onWifiConfigPreferenceAttached(boolean isNewNetwork) {
|
||||
if (isNewNetwork) {
|
||||
mStatusText.setText(R.string.wifi_setup_status_new_network);
|
||||
} else {
|
||||
mStatusText.setText(R.string.wifi_setup_status_existing_network);
|
||||
}
|
||||
mStatusText.setText(R.string.wifi_setup_status_edit_network);
|
||||
}
|
||||
|
||||
public void onForget() {
|
||||
|
Reference in New Issue
Block a user