Merge "Separate wifi AP added by applications."
This commit is contained in:
committed by
Android (Google) Code Review
commit
d7d604056b
@@ -69,6 +69,7 @@
|
|||||||
<uses-permission android:name="android.permission.MANAGE_DEVICE_ADMINS" />
|
<uses-permission android:name="android.permission.MANAGE_DEVICE_ADMINS" />
|
||||||
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
|
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
|
||||||
<uses-permission android:name="android.permission.OEM_UNLOCK_STATE" />
|
<uses-permission android:name="android.permission.OEM_UNLOCK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.OVERRIDE_WIFI_CONFIG" />
|
||||||
|
|
||||||
<application android:label="@string/settings_label"
|
<application android:label="@string/settings_label"
|
||||||
android:icon="@mipmap/ic_launcher_settings"
|
android:icon="@mipmap/ic_launcher_settings"
|
||||||
|
@@ -1503,6 +1503,10 @@
|
|||||||
<string name="wifi_menu_scan">Scan</string>
|
<string name="wifi_menu_scan">Scan</string>
|
||||||
<!-- Menu option to Wi-Fi advanced settings -->
|
<!-- Menu option to Wi-Fi advanced settings -->
|
||||||
<string name="wifi_menu_advanced">Advanced</string>
|
<string name="wifi_menu_advanced">Advanced</string>
|
||||||
|
<!-- Menu option to show app icons instead of WiFi strength [CHAR LIMIT=20]-->
|
||||||
|
<string name="wifi_menu_apps">Show Apps</string>
|
||||||
|
<!-- Menu option to show WiFi strength icons [CHAR LIMIT=20]-->
|
||||||
|
<string name="wifi_menu_apps_strength">Show WiFi Strength</string>
|
||||||
<!-- Menu option to connect to a Wi-Fi network -->
|
<!-- Menu option to connect to a Wi-Fi network -->
|
||||||
<string name="wifi_menu_connect">Connect to network</string>
|
<string name="wifi_menu_connect">Connect to network</string>
|
||||||
<!-- Menu option to delete a Wi-Fi network -->
|
<!-- Menu option to delete a Wi-Fi network -->
|
||||||
|
@@ -19,6 +19,8 @@ package com.android.settings.wifi;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.StateListDrawable;
|
import android.graphics.drawable.StateListDrawable;
|
||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
@@ -286,6 +288,26 @@ class AccessPoint extends Preference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showAppIcon() {
|
||||||
|
PackageManager pm = getContext().getPackageManager();
|
||||||
|
String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
|
||||||
|
|
||||||
|
Drawable drawable = pm.getDefaultActivityIcon();
|
||||||
|
if (mConfig == null) {
|
||||||
|
drawable.setAlpha(0);
|
||||||
|
} else if (mConfig.creatorName.equals(systemName)) {
|
||||||
|
drawable = getContext().getApplicationInfo().loadIcon(pm);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
drawable = pm.getApplicationIcon(mConfig.creatorName);
|
||||||
|
} catch (NameNotFoundException nnfe) {
|
||||||
|
// use default app icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setIcon(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Preference preference) {
|
public int compareTo(Preference preference) {
|
||||||
if (!(preference instanceof AccessPoint)) {
|
if (!(preference instanceof AccessPoint)) {
|
||||||
|
@@ -102,6 +102,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
private static final int MENU_ID_FORGET = Menu.FIRST + 7;
|
private static final int MENU_ID_FORGET = Menu.FIRST + 7;
|
||||||
private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
|
private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
|
||||||
private static final int MENU_ID_WRITE_NFC = Menu.FIRST + 9;
|
private static final int MENU_ID_WRITE_NFC = Menu.FIRST + 9;
|
||||||
|
private static final int MENU_ID_APPS = Menu.FIRST + 10;
|
||||||
|
|
||||||
private static final String KEY_ASSISTANT_DISMISS_PLATFORM = "assistant_dismiss_platform";
|
private static final String KEY_ASSISTANT_DISMISS_PLATFORM = "assistant_dismiss_platform";
|
||||||
|
|
||||||
@@ -142,6 +143,9 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
private TextView mEmptyView;
|
private TextView mEmptyView;
|
||||||
|
|
||||||
|
private boolean showAppIcons = false;
|
||||||
|
private MenuItem showAppMenuItem = null;
|
||||||
|
|
||||||
// this boolean extra specifies whether to disable the Next button when not connected. Used by
|
// this boolean extra specifies whether to disable the Next button when not connected. Used by
|
||||||
// account creation outside of setup wizard.
|
// account creation outside of setup wizard.
|
||||||
private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
|
private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
|
||||||
@@ -420,6 +424,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
|
menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
|
showAppMenuItem = menu.add(Menu.NONE, MENU_ID_APPS, 0, R.string.wifi_menu_apps);
|
||||||
|
showAppMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,6 +502,16 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case MENU_ID_APPS:
|
||||||
|
showAppIcons = !showAppIcons;
|
||||||
|
|
||||||
|
if (showAppIcons) {
|
||||||
|
showAppMenuItem.setTitle(R.string.wifi_menu_apps_strength);
|
||||||
|
} else {
|
||||||
|
showAppMenuItem.setTitle(R.string.wifi_menu_apps);
|
||||||
|
}
|
||||||
|
updateAccessPoints();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@@ -663,6 +679,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (AccessPoint accessPoint : accessPoints) {
|
for (AccessPoint accessPoint : accessPoints) {
|
||||||
|
if (showAppIcons) {
|
||||||
|
accessPoint.showAppIcon();
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore access points that are out of range.
|
// Ignore access points that are out of range.
|
||||||
if (accessPoint.getLevel() != -1) {
|
if (accessPoint.getLevel() != -1) {
|
||||||
getPreferenceScreen().addPreference(accessPoint);
|
getPreferenceScreen().addPreference(accessPoint);
|
||||||
|
Reference in New Issue
Block a user