Remove WifiSetupActivity

That activity was copied into setup wizard and is no longer used.

Also removed setup_illustration_lock_screen because that is also
not used in the current GLIF theme.

Test: Existing Robolectric tests pass
Bug: 33590605
Change-Id: Ib2ea02a5e4bce17a7ea829b854f73caf7d5c5f97
This commit is contained in:
Maurice Lam
2016-12-13 16:03:11 -08:00
parent af71eb20c8
commit f8a325c7c6
46 changed files with 3 additions and 744 deletions

View File

@@ -276,21 +276,6 @@
android:value="true" />
</activity>
<activity android:name=".wifi.WifiSetupActivity"
android:taskAffinity="com.android.wizard"
android:theme="@style/SetupWizardDisableAppStartingTheme"
android:label="@string/wifi_setup_wizard_title"
android:icon="@drawable/empty_icon"
android:clearTaskOnLaunch="true"
android:windowSoftInputMode="adjustNothing">
<intent-filter android:priority="1">
<action android:name="com.android.net.wifi.SETUP_WIFI_NETWORK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
<activity android:name="Settings$AdvancedWifiSettingsActivity"
android:taskAffinity="com.android.settings"
android:label="@string/wifi_advanced_settings_label"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

View File

@@ -1,30 +0,0 @@
<!--
Copyright (C) 2015 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25.0dp"
android:height="32.0dp"
android:viewportWidth="38.0"
android:viewportHeight="48.0">
<group android:translateX="5.0" android:translateY="10.0">
<path
android:fillColor="?android:attr/colorControlNormal"
android:pathData="M28.0,16.0L16.0,16.0l0.0,12.0l-4.0,0.0L12.0,16.0L0.0,16.0l0.0,-4.0l12.0,0.0L12.0,0.0l4.0,0.0l0.0,12.0l12.0,0.0l0.0,4.0z"/>
</group>
</vector>

View File

@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/ic_lock"
settings:suwHeaderText="@string/wifi_setup_wizard_title">
settings:suwHeaderText="@string/lockpassword_choose_your_pattern_header">
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
android:id="@+id/topLayout"

View File

@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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:id="@+id/other_network"
android:layout_width="match_parent"
android:layout_height="@dimen/setup_add_network_item_height"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingStart="?android:attr/listPreferredItemPaddingStart">
<LinearLayout
android:layout_width="@dimen/setup_preference_icon_frame_width"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/setup_preference_icon_frame_margin_start"
android:gravity="start|center_vertical"
android:paddingEnd="@dimen/setup_preference_icon_frame_padding_end">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/setup_ic_add_another_network" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_other_network"
android:textAppearance="@style/TextAppearance.SetupWizardDescription" />
</LinearLayout>

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/setup_wizard_margin_top"
android:paddingStart="@dimen/suw_layout_margin_sides"
android:paddingEnd="@dimen/suw_layout_margin_sides"
android:textAppearance="@style/TextAppearance.SetupWizardDescription" />

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2015, 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.
-->
<com.android.setupwizardlib.SetupWizardListLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
settings:suwBackgroundTile="@drawable/setup_illustration_tile"
settings:suwHeaderText="@string/wifi_setup_wizard_title"
settings:suwIllustrationHorizontalTile="@drawable/setup_illustration_horizontal_tile"
settings:suwIllustrationImage="@drawable/setup_illustration_wifi" />

View File

@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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="@dimen/setup_add_network_item_height"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:textDirection="locale">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/setup_list_no_icon_padding"
android:text="@string/wifi_advanced_mac_address_title" />
<TextView
android:id="@+id/mac_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/setup_list_no_icon_padding" />
</LinearLayout>

View File

@@ -40,14 +40,6 @@
<dimen name="crypt_clock_size">100sp</dimen>
<dimen name="setup_add_network_item_height">56dp</dimen>
<!-- Size of padding to give in the wifi list when there is no icon -->
<dimen name="setup_list_no_icon_padding">56dp</dimen>
<dimen name="setup_preference_icon_frame_margin_start">-4dp</dimen>
<dimen name="setup_preference_icon_frame_padding_end">12dp</dimen>
<dimen name="setup_preference_icon_frame_width">60dp</dimen>
<dimen name="setup_wizard_margin_top">24dp</dimen>
<dimen name="divider_height">3dip</dimen>
<dimen name="divider_margin_top">6dip</dimen>
<dimen name="divider_margin_bottom">7dip</dimen>

View File

@@ -1568,8 +1568,6 @@
<string name="wifi_settings_title">Wi\u2011Fi</string>
<!-- Summary text of the Wi-fi settings screen -->
<string name="wifi_settings_summary">Set up &amp; manage wireless access points</string>
<!-- Used in the 1st-level settings screen to turn on Wi-Fi [CHAR LIMIT=60] -->
<string name="wifi_setup_wizard_title">Select Wi\u2011Fi network</string>
<!-- Used by Account creation for turning on Wi-Fi [CHAR LIMIT=60] -->
<string name="wifi_select_network">Select Wi\u2011Fi</string>
<!-- Summary text when turning Wi-Fi or bluetooth on -->
@@ -1663,8 +1661,6 @@
<string name="wifi_empty_list_wifi_on">Searching for Wi\u2011Fi networks\u2026</string>
<!-- Wifi Settings. text displayed when user has restriction DISALLOW_CONFIG_WIFI [CHAR LIMIT=NONE]-->
<string name="wifi_empty_list_user_restricted">You don\u2019t have permission to change the Wi\u2011Fi network.</string>
<!-- Wi-Fi settings. title for setup other network button [CHAR LIMIT=35]-->
<string name="wifi_other_network">Add another network</string>
<!-- Wi-Fi settings. content description for more button [CHAR LIMIT=50]-->
<string name="wifi_more">More</string>
<!-- Wi-Fi settings. wps menu title [CHAR LIMIT=25]-->
@@ -1813,30 +1809,6 @@
<string name="wifi_failed_save_message">Failed to save network</string>
<!-- Button label to dismiss the dialog -->
<string name="wifi_cancel">Cancel</string>
<!-- Button for skipping a step after having been warned of a potential concern [CHAR LIMIT=30] -->
<string name="wifi_skip_anyway">Skip anyway</string>
<!-- Button for going to the previous screen or step [CHAR LIMIT=20] -->
<string name="wifi_dont_skip">Go back</string>
<!-- Text warning about skipping Wi-Fi with a mobile connect (tablet) [CHAR LIMIT=NONE]-->
<string name="wifi_skipped_message" product="tablet">WARNING: if you skip Wi\u2011Fi, your tablet will only use cellular data for initial downloads and updates. To avoid possible data charges, connect to Wi\u2011Fi.</string>
<!-- Text warning about skipping Wi-Fi with a mobile connect (device) [CHAR LIMIT=NONE]-->
<string name="wifi_skipped_message" product="device">WARNING: if you skip Wi\u2011Fi, your device will only use cellular data for initial downloads and updates. To avoid possible data charges, connect to Wi\u2011Fi.</string>
<!-- Text warning about skipping Wi-Fi with a mobile connect (phone) [CHAR LIMIT=NONE]-->
<string name="wifi_skipped_message" product="default">WARNING: if you skip Wi\u2011Fi, your phone will only use cellular data for initial downloads and updates. To avoid possible data charges, connect to Wi\u2011Fi.</string>
<!-- Text warning about skipping Wi-Fi without a mobile connect (tablet) [CHAR LIMIT=NONE] -->
<string name="wifi_and_mobile_skipped_message" product="tablet">If you skip Wi\u2011Fi:\n\n<li>Your tablet won\u2019t have an Internet connection.</li>\n\n<li>You won\u2019t get software updates until you connect to the Internet.</li>\n\n<li>You can\u2019t activate device protection features at this time.</li></string>
<!-- Text warning about skipping Wi-Fi without a mobile connect (device) [CHAR LIMIT=NONE] -->
<string name="wifi_and_mobile_skipped_message" product="device">If you skip Wi\u2011Fi:\n\n<li>Your device won\u2019t have an Internet connection.</li>\n\n<li>You won\u2019t get software updates until you connect to the Internet.</li>\n\n<li>You can\u2019t activate device protection features at this time.</li></string>
<!-- Text warning about skipping Wi-Fi without a mobile connect (phone) [CHAR LIMIT=NONE] -->
<string name="wifi_and_mobile_skipped_message" product="default">If you skip Wi\u2011Fi:\n\n<li>Your phone won\u2019t have an Internet connection.</li>\n\n<li>You won\u2019t get software updates until you connect to the Internet.</li>\n\n<li>You can\u2019t activate device protection features at this time.</li></string>
<!-- Text alerting that Wi-Fi couldn't connect (tablet) [CHAR LIMIT=NONE] -->
<string name="wifi_connect_failed_message" product="tablet">The tablet was unable to connect to this Wi\u2011Fi network.</string>
<!-- Text alerting that Wi-Fi couldn't connect (device) [CHAR LIMIT=NONE] -->
<string name="wifi_connect_failed_message" product="device">The device was unable to connect to this Wi\u2011Fi network.</string>
<!-- Text alerting that Wi-Fi couldn't connect (phone) [CHAR LIMIT=NONE] -->
<string name="wifi_connect_failed_message" product="default">The phone was unable to connect to this Wi\u2011Fi network.</string>
<!-- Wi-Fi Advanced Settings --> <skip />
<!-- Wi-Fi settings screen, Saved networks, settings section. This is a header shown above Saved networks wifi settings. [CHAR LIMIT=30] -->

View File

@@ -140,9 +140,6 @@
<item name="android:scrollbarStyle">outsideOverlay</item>
</style>
<style name="TextAppearance.SetupWizardDescription" parent="@android:style/TextAppearance.Material.Subhead">
</style>
<style name="TrimmedHorizontalProgressBar" parent="android:Widget.Material.ProgressBar.Horizontal">
<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_material_trimmed</item>
<item name="android:minHeight">3dip</item>

View File

@@ -22,13 +22,6 @@
<attr name="side_margin" format="reference|dimension" />
<attr name="wifi_signal_color" format="reference" />
<style name="SetupWizardDisableAppStartingTheme">
<!-- Theme to disable the app starting window. The actual theme of the activity needs to
be then set in code via setTheme or onApplyThemeResource. -->
<item name="preferenceTheme">@style/PreferenceTheme.SetupWizard</item>
<item name="android:windowBackground">@null</item>
</style>
<style name="SetupWizardTheme" parent="SuwThemeGlif">
<!-- For all Alert Dialogs -->
<item name="android:alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>

View File

@@ -16,11 +16,8 @@
package com.android.settings;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import com.android.setupwizardlib.util.SystemBarHelper;
import com.android.setupwizardlib.util.WizardManagerHelper;
public class SetupWizardUtils {
@@ -41,22 +38,6 @@ public class SetupWizardUtils {
}
}
/**
* Sets the immersive mode related flags based on the extra in the intent which started the
* activity.
*/
public static void setImmersiveMode(Activity activity) {
final boolean useImmersiveMode = activity.getIntent().getBooleanExtra(
WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false);
if (useImmersiveMode) {
SystemBarHelper.hideSystemBars(activity.getWindow());
}
}
public static void applyImmersiveFlags(final Dialog dialog) {
SystemBarHelper.hideSystemBars(dialog);
}
public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
toIntent.putExtra(WizardManagerHelper.EXTRA_THEME,
fromIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));

View File

@@ -19,7 +19,6 @@ package com.android.settings.fingerprint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.content.Intent;
@@ -93,7 +92,7 @@ public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling
.setTitle(R.string.setup_fingerprint_enroll_enrolling_skip_title)
.setMessage(R.string.setup_fingerprint_enroll_enrolling_skip_message)
.setCancelable(false)
.setPositiveButton(R.string.wifi_skip_anyway,
.setPositiveButton(R.string.skip_anyway_button_label,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
@@ -104,7 +103,7 @@ public class SetupFingerprintEnrollEnrolling extends FingerprintEnrollEnrolling
}
}
})
.setNegativeButton(R.string.wifi_dont_skip,
.setNegativeButton(R.string.go_back_button_label,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {

View File

@@ -1,205 +0,0 @@
/*
* Copyright (C) 2014 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.app.Dialog;
import android.net.wifi.WifiConfiguration;
import android.os.Bundle;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.setupwizardlib.SetupWizardListLayout;
import com.android.setupwizardlib.view.NavigationBar;
/**
* This customized version of WifiSettings is shown to the user only during Setup Wizard. Menu
* is not shown, clicking on an access point will auto-advance to the next screen (once connected),
* and, if the user opts to skip ahead without a wifi connection, a warning message alerts of
* possible carrier data charges or missing software updates.
*/
public class WifiSettingsForSetupWizard extends WifiSettings {
private static final String TAG = "WifiSettingsForSetupWizard";
private SetupWizardListLayout mLayout;
private View mAddOtherNetworkItem;
private TextView mEmptyFooter;
private View mMacAddressFooter;
private boolean mListLastEmpty = false;
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mLayout = (SetupWizardListLayout)
inflater.inflate(R.layout.setup_wifi_layout, container, false);
final ListView list = mLayout.getListView();
mAddOtherNetworkItem = inflater.inflate(R.layout.setup_wifi_add_network, list, false);
list.addFooterView(mAddOtherNetworkItem, null, true);
mAddOtherNetworkItem.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mWifiManager.isWifiEnabled()) {
onAddNetworkPressed();
}
}
});
mMacAddressFooter = inflater.inflate(R.layout.setup_wifi_mac_address, list, false);
list.addFooterView(mMacAddressFooter, null, false);
final NavigationBar navigationBar = mLayout.getNavigationBar();
if (navigationBar != null) {
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
activity.onNavigationBarCreated(navigationBar);
}
return mLayout;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (hasNextButton()) {
getNextButton().setVisibility(View.GONE);
}
updateMacAddress();
}
@Override
public void onAccessPointsChanged() {
super.onAccessPointsChanged();
PreferenceScreen preferenceScreen = getPreferenceScreen();
updateFooter(preferenceScreen == null || preferenceScreen.getPreferenceCount() == 0);
}
@Override
public void onWifiStateChanged(int state) {
super.onWifiStateChanged(state);
updateMacAddress();
}
@Override
public void registerForContextMenu(View view) {
// Suppressed during setup wizard
}
@Override
/* package */ WifiEnabler createWifiEnabler() {
// Not shown during setup wizard
return null;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Do not show menu during setup wizard
}
@Override
public Dialog onCreateDialog(int dialogId) {
final Dialog dialog = super.onCreateDialog(dialogId);
SetupWizardUtils.applyImmersiveFlags(dialog);
return dialog;
}
@Override
protected void connect(final WifiConfiguration config, boolean isSavedNetwork) {
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
activity.networkSelected();
super.connect(config, isSavedNetwork);
}
@Override
protected void connect(final int networkId, boolean isSavedNetwork) {
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
activity.networkSelected();
super.connect(networkId, isSavedNetwork);
}
@Override
protected TextView initEmptyTextView() {
final LayoutInflater inflater = LayoutInflater.from(getActivity());
mEmptyFooter = (TextView) inflater.inflate(R.layout.setup_wifi_empty, getListView(), false);
return mEmptyFooter;
}
protected void updateFooter(boolean isEmpty) {
if (isEmpty != mListLastEmpty) {
if (isEmpty) {
setFooterView(mEmptyFooter);
} else {
LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(mAddOtherNetworkItem);
layout.addView(mMacAddressFooter);
setFooterView(layout);
}
mListLastEmpty = isEmpty;
}
}
@Override
public View setPinnedHeaderView(int layoutResId) {
// Pinned header is not supported in setup wizard
return null;
}
@Override
public void setPinnedHeaderView(View pinnedHeader) {
// Pinned header is not supported in setup wizard
}
@Override
protected void setProgressBarVisible(boolean visible) {
if (mLayout != null) {
if (visible) {
mLayout.showProgressBar();
} else {
mLayout.hideProgressBar();
}
}
}
private void updateMacAddress() {
if (mMacAddressFooter != null) {
String macAddress = null;
if (mWifiManager != null) {
android.net.wifi.WifiInfo connectionInfo = mWifiManager.getConnectionInfo();
if (connectionInfo != null) {
macAddress = connectionInfo.getMacAddress();
}
}
final TextView macAddressTextView =
(TextView) mMacAddressFooter.findViewById(R.id.mac_address);
macAddressTextView.setText(!TextUtils.isEmpty(macAddress) ?
macAddress : getString(R.string.status_unavailable));
}
}
}

View File

@@ -1,288 +0,0 @@
/*
* Copyright (C) 2012 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.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.support.v14.preference.PreferenceFragment;
import android.util.Log;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.ButtonBarHandler;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.setupwizardlib.view.NavigationBar;
public class WifiSetupActivity extends WifiPickerActivity
implements ButtonBarHandler, NavigationBar.NavigationBarListener {
private static final String TAG = "WifiSetupActivity";
// this boolean extra specifies whether to auto finish when connection is established
private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
// This boolean extra specifies whether network is required
private static final String EXTRA_IS_NETWORK_REQUIRED = "is_network_required";
// This boolean extra specifies whether wifi is required
private static final String EXTRA_IS_WIFI_REQUIRED = "is_wifi_required";
// Whether auto finish is suspended until user connects to an access point
private static final String EXTRA_REQUIRE_USER_NETWORK_SELECTION =
"wifi_require_user_network_selection";
// Key for whether the user selected network in saved instance state bundle
private static final String PARAM_USER_SELECTED_NETWORK = "userSelectedNetwork";
// Activity result when pressing the Skip button
private static final int RESULT_SKIP = Activity.RESULT_FIRST_USER;
// Whether to auto finish when the user selected a network and successfully connected
private boolean mAutoFinishOnConnection;
// Whether network is required to proceed. This is decided in SUW and passed in as an extra.
private boolean mIsNetworkRequired;
// Whether wifi is required to proceed. This is decided in SUW and passed in as an extra.
private boolean mIsWifiRequired;
// Whether the user connected to a network. This excludes the auto-connecting by the system.
private boolean mUserSelectedNetwork;
// Whether the device is connected to WiFi
private boolean mWifiConnected;
private NavigationBar mNavigationBar;
private IntentFilter mFilter = new IntentFilter();
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Refresh the connection state with the latest connection info. Use the connection info
// from ConnectivityManager instead of the one attached in the intent to make sure
// we have the most up-to-date connection state. b/17511772
refreshConnectionState();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent intent = getIntent();
mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
mFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
mAutoFinishOnConnection = intent.getBooleanExtra(EXTRA_AUTO_FINISH_ON_CONNECT, false);
mIsNetworkRequired = intent.getBooleanExtra(EXTRA_IS_NETWORK_REQUIRED, false);
mIsWifiRequired = intent.getBooleanExtra(EXTRA_IS_WIFI_REQUIRED, false);
// Behave like the user already selected a network if we do not require selection
mUserSelectedNetwork = !intent.getBooleanExtra(EXTRA_REQUIRE_USER_NETWORK_SELECTION, false);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(PARAM_USER_SELECTED_NETWORK, mUserSelectedNetwork);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mUserSelectedNetwork = savedInstanceState.getBoolean(PARAM_USER_SELECTED_NETWORK, true);
}
private boolean isWifiConnected() {
final ConnectivityManager connectivity = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
boolean wifiConnected = connectivity != null &&
connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
mWifiConnected = wifiConnected;
return wifiConnected;
}
private void refreshConnectionState() {
if (isWifiConnected()) {
if (mAutoFinishOnConnection && mUserSelectedNetwork) {
Log.d(TAG, "Auto-finishing with connection");
finish(Activity.RESULT_OK);
// Require a user selection before auto-finishing next time we are here. The user
// can either connect to a different network or press "next" to proceed.
mUserSelectedNetwork = false;
}
setNextButtonText(R.string.suw_next_button_label);
setNextButtonEnabled(true);
} else if (mIsWifiRequired || (mIsNetworkRequired && !isNetworkConnected())) {
// We do not want the user to skip wifi setting if
// - wifi is required, but wifi connection hasn't been established yet;
// - or network is required, but no valid connection has been established.
setNextButtonText(R.string.skip_label);
setNextButtonEnabled(false);
} else {
// In other cases, user can choose to skip. Specifically these cases are
// - wifi is not required;
// - and network is not required;
// - or network is required and a valid connection has been established.
setNextButtonText(R.string.skip_label);
setNextButtonEnabled(true);
}
}
private void setNextButtonEnabled(boolean enabled) {
if (mNavigationBar != null) {
mNavigationBar.getNextButton().setEnabled(enabled);
}
}
private void setNextButtonText(int resId) {
if (mNavigationBar != null) {
mNavigationBar.getNextButton().setText(resId);
}
}
/* package */ void networkSelected() {
Log.d(TAG, "Network selected by user");
mUserSelectedNetwork = true;
}
@Override
public void onResume() {
super.onResume();
registerReceiver(mReceiver, mFilter);
refreshConnectionState();
}
@Override
public void onPause() {
unregisterReceiver(mReceiver);
super.onPause();
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent());
super.onApplyThemeResource(theme, resid, first);
}
@Override
protected boolean isValidFragment(String fragmentName) {
return WifiSettingsForSetupWizard.class.getName().equals(fragmentName);
}
@Override
/* package */ Class<? extends PreferenceFragment> getWifiSettingsClass() {
return WifiSettingsForSetupWizard.class;
}
/**
* Complete this activity and return the results to the caller.
*/
public void finish(int resultCode) {
Log.d(TAG, "finishing, resultCode=" + resultCode);
setResult(resultCode);
finish();
}
public void onNavigationBarCreated(final NavigationBar bar) {
mNavigationBar = bar;
bar.setNavigationBarListener(this);
SetupWizardUtils.setImmersiveMode(this);
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
if (mWifiConnected) {
finish(RESULT_OK);
} else {
// Warn of possible data charges if there is a network connection, or lack of updates
// if there is none.
final int message = isNetworkConnected() ? R.string.wifi_skipped_message :
R.string.wifi_and_mobile_skipped_message;
WifiSkipDialog.newInstance(message).show(getFragmentManager(), "dialog");
}
}
/**
* @return True if there is a valid network connection, whether it is via WiFi, mobile data or
* other means.
*/
private boolean isNetworkConnected() {
final ConnectivityManager connectivity = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
}
final NetworkInfo info = connectivity.getActiveNetworkInfo();
return info != null && info.isConnected();
}
public static class WifiSkipDialog extends InstrumentedDialogFragment {
public static WifiSkipDialog newInstance(int messageRes) {
final Bundle args = new Bundle();
args.putInt("messageRes", messageRes);
final WifiSkipDialog dialog = new WifiSkipDialog();
dialog.setArguments(args);
return dialog;
}
public WifiSkipDialog() {
// no-arg constructor for fragment
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.DIALOG_WIFI_SKIP;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
int messageRes = getArguments().getInt("messageRes");
final AlertDialog dialog = new AlertDialog.Builder(getActivity())
.setMessage(messageRes)
.setCancelable(false)
.setPositiveButton(R.string.wifi_skip_anyway,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
activity.finish(RESULT_SKIP);
}
})
.setNegativeButton(R.string.wifi_dont_skip,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
})
.create();
SetupWizardUtils.applyImmersiveFlags(dialog);
return dialog;
}
}
}

View File

@@ -1,3 +1,2 @@
com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
com.android.settings.wifi.WifiSettingsForSetupWizard
com.android.settings.print.PrintServiceSettingsFragment