Remove the Wi-Fi Assistant card.
Per the latest mocks, advanced wireless settings will be the only location in platform settings where Wi-Fi Assistants are configured. The card is no longer being used. Bug: 13780935 Change-Id: Idddf971404532256165045665bd0a6b19966d2bd
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 38 KiB |
@@ -1,81 +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/wifi_assistant_card"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/wifi_assistant_height">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cardBackground"
|
||||
android:background="@color/wifi_assistant_color_accent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/wifi_assistant_card" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/backgroundText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/wifi_assistant_text_padding"
|
||||
android:gravity="start"
|
||||
android:paddingStart="@dimen/wifi_assistant_padding_start_end"
|
||||
android:paddingTop="@dimen/wifi_assistant_padding_top_bottom"
|
||||
android:text="@string/wifi_assistant_intro_setup"
|
||||
style="@style/WifiAssistantText" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wifi_assistant_text"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginBottom="@dimen/wifi_assistant_padding_top_bottom"
|
||||
android:layout_marginTop="@dimen/wifi_assistant_padding_top_bottom"
|
||||
android:layout_marginLeft="@dimen/wifi_assistant_padding_start_end"
|
||||
android:layout_marginRight="@dimen/wifi_assistant_padding_start_end"
|
||||
android:gravity="start"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:background="@android:color/transparent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:gravity="end"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/no_thanks_button"
|
||||
android:text="@string/wifi_assistant_no_thanks"
|
||||
style="@style/WifiAssistantButton.Negative" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/setup"
|
||||
android:text="@string/wifi_assistant_setup"
|
||||
style="@style/WifiAssistantButton.Positive" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@@ -45,8 +45,6 @@
|
||||
<color name="setup_wizard_wifi_color_dark">#ff00e4ff</color>
|
||||
<color name="setup_wizard_wifi_color_light">#ff0096a6</color>
|
||||
|
||||
<color name="wifi_assistant_color_accent">#ff009587</color>
|
||||
|
||||
<color name="circle_avatar_frame_color">#ffffffff</color>
|
||||
<color name="circle_avatar_frame_shadow_color">#80000000</color>
|
||||
<color name="circle_avatar_frame_pressed_color">#ffffffff</color>
|
||||
|
@@ -1328,20 +1328,8 @@
|
||||
<!-- Bluetooth settings. Dock Setting Dialog - Remember setting and don't ask user again -->
|
||||
<string name="bluetooth_dock_settings_remember">Remember settings</string>
|
||||
|
||||
<!-- Wifi Assistant title string. [CHAR LIMIT=40] -->
|
||||
<string name="wifi_assistant_intro_setup">Introducing\nWi\u2011Fi Assistant</string>
|
||||
<!-- Wifi Assistant No, thanks string. Text to say no to wifi assistant. [CHAR LIMIT=20] -->
|
||||
<string name="wifi_assistant_no_thanks">NO, THANKS</string>
|
||||
<!-- Wifi Assistant setup string. Text to say yes to wifi assistant and begin setup. [CHAR LIMIT=20] -->
|
||||
<string name="wifi_assistant_setup">SET UP</string>
|
||||
<!-- Wifi Assistant card message. [CHAR LIMIT=200] -->
|
||||
<string name="wifi_assistant_card_message">Automatically connect to available networks with a Wi\u2011Fi Assistant.</string>
|
||||
<!-- Wifi Assistant title. [CHAR LIMIT=40] -->
|
||||
<string name="wifi_assistant_title">Wi\u2011Fi Assistant</string>
|
||||
<!-- Wifi Assistant title message. First piece of text on the Wifi Assistant setup wizard. [CHAR LIMIT=200] -->
|
||||
<string name="wifi_assistant_title_message"><xliff:g id="wifi_assistant">%1$s</xliff:g> automatically connects you to the best available Wi\u2011Fi</string>
|
||||
<!-- Wifi Assistant open app button text. [CHAR LIMIT=40] -->
|
||||
<string name="wifi_assistant_open_app">OPEN APP</string>
|
||||
|
||||
<!-- Wifi Display settings. The title of the screen. [CHAR LIMIT=40] -->
|
||||
<string name="wifi_display_settings_title">Cast screen</string>
|
||||
|
@@ -305,27 +305,6 @@
|
||||
<item name="android:textSize">18sp</item>
|
||||
</style>
|
||||
|
||||
<style name="WifiAssistantText">
|
||||
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="WifiAssistantButton">
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:background">@android:color/white</item>
|
||||
<item name="android:paddingStart">@dimen/wifi_assistant_text_padding</item>
|
||||
<item name="android:paddingEnd">@dimen/wifi_assistant_text_padding</item>
|
||||
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
|
||||
</style>
|
||||
|
||||
<style name="WifiAssistantButton.Negative">
|
||||
</style>
|
||||
|
||||
<style name="WifiAssistantButton.Positive">
|
||||
<item name="android:textColor">@color/wifi_assistant_color_accent</item>
|
||||
</style>
|
||||
|
||||
<!-- Scrollbar style OUTSIDE_OVERLAY -->
|
||||
<integer name="preference_scrollbar_style">33554432</integer>
|
||||
|
||||
|
@@ -129,7 +129,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
pref.setIntent(intent);
|
||||
|
||||
final Context context = getActivity();
|
||||
NetworkScorerAppData scorer = WifiSettings.getWifiAssistantApp(context);
|
||||
NetworkScorerAppData scorer = getWifiAssistantApp(context);
|
||||
SwitchPreference wifiAssistant = (SwitchPreference)findPreference(KEY_WIFI_ASSISTANT);
|
||||
if (scorer != null) {
|
||||
final boolean checked = NetworkScorerAppManager.getActiveScorer(context) != null;
|
||||
@@ -265,7 +265,7 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
return true;
|
||||
}
|
||||
|
||||
NetworkScorerAppData wifiAssistant = WifiSettings.getWifiAssistantApp(context);
|
||||
NetworkScorerAppData wifiAssistant = getWifiAssistantApp(context);
|
||||
Intent intent = new Intent();
|
||||
if (wifiAssistant.mConfigurationActivityClassName != null) {
|
||||
// App has a custom configuration activity; launch that.
|
||||
@@ -316,6 +316,22 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
|
||||
wifiIpAddressPref.setSelectable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Network Scorer for the Wifi Assistant App.
|
||||
*/
|
||||
public static NetworkScorerAppData getWifiAssistantApp(Context context) {
|
||||
Collection<NetworkScorerAppData> scorers =
|
||||
NetworkScorerAppManager.getAllValidScorers(context);
|
||||
|
||||
if (scorers.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: b/13780935 - Implement proper scorer selection. Rather than pick the first
|
||||
// scorer on the system, we should allow the user to select one.
|
||||
return scorers.iterator().next();
|
||||
}
|
||||
|
||||
/* Wrapper class for the WPS dialog to properly handle life cycle events like rotation. */
|
||||
public static class WpsFragment extends DialogFragment {
|
||||
private static int mWpsSetup;
|
||||
|
@@ -27,7 +27,6 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.location.LocationManager;
|
||||
@@ -35,15 +34,11 @@ import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
import android.net.NetworkInfo.State;
|
||||
import android.net.NetworkScoreManager;
|
||||
import android.net.NetworkScorerAppManager;
|
||||
import android.net.NetworkScorerAppManager.NetworkScorerAppData;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WpsInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@@ -53,14 +48,11 @@ import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -91,8 +83,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
|
||||
private static final String TAG = "WifiSettings";
|
||||
|
||||
private static final int REQUEST_ENABLE_WIFI_ASSISTANT = 1;
|
||||
|
||||
/* package */ static final int MENU_ID_WPS_PBC = Menu.FIRST;
|
||||
private static final int MENU_ID_WPS_PIN = Menu.FIRST + 1;
|
||||
private static final int MENU_ID_SAVED_NETWORK = Menu.FIRST + 2;
|
||||
@@ -104,8 +94,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
|
||||
private static final int MENU_ID_WRITE_NFC = Menu.FIRST + 9;
|
||||
|
||||
private static final String KEY_ASSISTANT_DISMISS_PLATFORM = "assistant_dismiss_platform";
|
||||
|
||||
public static final int WIFI_DIALOG_ID = 1;
|
||||
/* package */ static final int WPS_PBC_DIALOG_ID = 2;
|
||||
private static final int WPS_PIN_DIALOG_ID = 3;
|
||||
@@ -157,8 +145,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
private boolean mDlgEdit;
|
||||
private AccessPoint mDlgAccessPoint;
|
||||
private Bundle mAccessPointSavedState;
|
||||
private View mWifiAssistantCard;
|
||||
private NetworkScorerAppData mWifiAssistantApp;
|
||||
|
||||
/** verbose logging flag. this flag is set thru developer debugging options
|
||||
* and used so as to assist with in-the-field WiFi connectivity debugging */
|
||||
@@ -325,8 +311,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
|
||||
addPreferencesFromResource(R.xml.wifi_settings);
|
||||
|
||||
prepareWifiAssistantCard();
|
||||
|
||||
mEmptyView = initEmptyView();
|
||||
registerForContextMenu(getListView());
|
||||
setHasOptionsMenu(true);
|
||||
@@ -349,19 +333,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
|
||||
if (requestCode == REQUEST_ENABLE_WIFI_ASSISTANT) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
disableWifiAssistantCardUntilPlatformUpgrade();
|
||||
getListView().removeHeaderView(mWifiAssistantCard);
|
||||
mWifiAssistantApp = null;
|
||||
}
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, resultData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
@@ -692,11 +663,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
addMessagePreference(R.string.wifi_empty_list_wifi_on);
|
||||
}
|
||||
|
||||
getListView().removeHeaderView(mWifiAssistantCard);
|
||||
if (mWifiAssistantApp != null) {
|
||||
getListView().addHeaderView(mWifiAssistantCard);
|
||||
}
|
||||
|
||||
for (AccessPoint accessPoint : accessPoints) {
|
||||
// Ignore access points that are out of range.
|
||||
if (accessPoint.getLevel() != -1) {
|
||||
@@ -719,102 +685,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Network Scorer for the Wifi Assistant App.
|
||||
*/
|
||||
public static NetworkScorerAppData getWifiAssistantApp(Context context) {
|
||||
Collection<NetworkScorerAppData> scorers =
|
||||
NetworkScorerAppManager.getAllValidScorers(context);
|
||||
|
||||
if (scorers.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: b/13780935 - Implement proper scorer selection. Rather than pick the first
|
||||
// scorer on the system, we should allow the user to select one.
|
||||
return scorers.iterator().next();
|
||||
}
|
||||
|
||||
private void prepareWifiAssistantCard() {
|
||||
if (getActivity() instanceof WifiPickerActivity) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NetworkScorerAppManager.getActiveScorer(getActivity()) != null) {
|
||||
// A scorer is already enabled; don't show the card.
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<NetworkScorerAppData> scorers =
|
||||
NetworkScorerAppManager.getAllValidScorers(getActivity());
|
||||
if (scorers.isEmpty()) {
|
||||
// No scorers are available to enable; don't show the card.
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
||||
int lastDismissPlatform = sharedPreferences.getInt(KEY_ASSISTANT_DISMISS_PLATFORM, 0);
|
||||
|
||||
if (Build.VERSION.SDK_INT <= lastDismissPlatform) {
|
||||
// User has dismissed the Wi-Fi assistant card on this SDK release. Suppress the card
|
||||
// until the next major platform upgrade.
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: b/13780935 - Implement proper scorer selection. Rather than pick the first
|
||||
// scorer on the system, we should allow the user to select one.
|
||||
mWifiAssistantApp = scorers.iterator().next();
|
||||
|
||||
if (mWifiAssistantCard == null) {
|
||||
mWifiAssistantCard = LayoutInflater.from(getActivity())
|
||||
.inflate(R.layout.wifi_assistant_card, getListView(), false);
|
||||
Button setup = (Button) mWifiAssistantCard.findViewById(R.id.setup);
|
||||
Button noThanks = (Button) mWifiAssistantCard.findViewById(R.id.no_thanks_button);
|
||||
TextView assistantText =
|
||||
(TextView) mWifiAssistantCard.findViewById(R.id.wifi_assistant_text);
|
||||
assistantText.setText(getResources().getString(
|
||||
R.string.wifi_assistant_title_message, mWifiAssistantApp.mScorerName));
|
||||
|
||||
if (setup != null && noThanks != null) {
|
||||
setup.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent();
|
||||
if (mWifiAssistantApp.mConfigurationActivityClassName != null) {
|
||||
// App has a custom configuration activity; launch that.
|
||||
// This custom activity will be responsible for launching the system
|
||||
// dialog.
|
||||
intent.setClassName(mWifiAssistantApp.mPackageName,
|
||||
mWifiAssistantApp.mConfigurationActivityClassName);
|
||||
} else {
|
||||
// Fall back on the system dialog.
|
||||
intent.setAction(NetworkScoreManager.ACTION_CHANGE_ACTIVE);
|
||||
intent.putExtra(NetworkScoreManager.EXTRA_PACKAGE_NAME,
|
||||
mWifiAssistantApp.mPackageName);
|
||||
}
|
||||
startActivityForResult(intent, REQUEST_ENABLE_WIFI_ASSISTANT);
|
||||
}
|
||||
});
|
||||
|
||||
noThanks.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
disableWifiAssistantCardUntilPlatformUpgrade();
|
||||
getListView().removeHeaderView(mWifiAssistantCard);
|
||||
mWifiAssistantApp = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void disableWifiAssistantCardUntilPlatformUpgrade() {
|
||||
SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt(KEY_ASSISTANT_DISMISS_PLATFORM, Build.VERSION.SDK_INT);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
protected TextView initEmptyView() {
|
||||
TextView emptyView = (TextView) getActivity().findViewById(android.R.id.empty);
|
||||
getListView().setEmptyView(emptyView);
|
||||
|