<string name="wifi_menu_scan">Scan</string>
<!-- Menu option to Wi-Fi advanced settings -->
<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 -->
<string name="wifi_menu_connect">Connect to network</string>
<!-- Menu option to remember a temporary Wi-Fi network -->
*/
package com.android.settings.wifi;
-import android.app.AppGlobals;
import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.IPackageManager;
-import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
-import android.net.wifi.WifiConfiguration;
-import android.os.RemoteException;
-import android.os.UserHandle;
import android.preference.Preference;
import android.view.View;
import android.widget.TextView;
notifyChanged();
}
- public void showAppIcon() {
- PackageManager pm = getContext().getPackageManager();
- String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
- WifiConfiguration mConfig = mAccessPoint.getConfig();
-
- Drawable drawable = pm.getDefaultActivityIcon();
- if (mConfig == null) {
- drawable.setAlpha(0);
- } else {
- int userId = UserHandle.getUserId(mConfig.creatorUid);
- ApplicationInfo appInfo = null;
- if (mConfig.creatorName.equals(systemName)) {
- appInfo = getContext().getApplicationInfo();
- } else {
- try {
- IPackageManager ipm = AppGlobals.getPackageManager();
- appInfo = ipm.getApplicationInfo(mConfig.creatorName, 0 /* flags */, userId);
- } catch (RemoteException rex) {
- // use default app icon
- }
- }
- if (appInfo != null) {
- drawable = appInfo.loadIcon(pm);
- drawable = pm.getUserBadgedIcon(drawable, new UserHandle(userId));
- }
- }
-
- setIcon(drawable);
- }
-
protected void updateIcon(int level, Context context) {
if (level == -1) {
setIcon(null);
package com.android.settings.wifi;
+import android.app.AppGlobals;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
+import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.UserHandle;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.util.Log;
preferenceScreen.removeAll();
+ PackageManager pm = context.getPackageManager();
+ String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
+
final int accessPointsSize = accessPoints.size();
for (int i = 0; i < accessPointsSize; ++i){
AccessPointPreference preference = new AccessPointPreference(accessPoints.get(i),
context);
- preference.setShowSummary(false);
+ WifiConfiguration config = accessPoints.get(i).getConfig();
+ if (config != null) {
+ int userId = UserHandle.getUserId(config.creatorUid);
+ ApplicationInfo appInfo = null;
+ if (config.creatorName != null && config.creatorName.equals(systemName)) {
+ appInfo = context.getApplicationInfo();
+ } else {
+ try {
+ IPackageManager ipm = AppGlobals.getPackageManager();
+ appInfo = ipm.getApplicationInfo(config.creatorName, 0 /* flags */, userId);
+ } catch (RemoteException rex) {
+ }
+ }
+ if (appInfo != null) {
+ preference.setSummary(getResources().getString(appInfo.labelRes));
+ }
+ } else {
+ preference.setShowSummary(false);
+ }
preferenceScreen.addPreference(preference);
}
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_WRITE_NFC = Menu.FIRST + 9;
- private static final int MENU_ID_APPS = Menu.FIRST + 10;
public static final int WIFI_DIALOG_ID = 1;
/* package */ static final int WPS_PBC_DIALOG_ID = 2;
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
// account creation outside of setup wizard.
private static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
.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();
}
null);
}
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);
- }
- onAccessPointsChanged();
- return true;
}
return super.onOptionsItemSelected(item);
}
if (accessPoint.getLevel() != -1) {
AccessPointPreference preference = new AccessPointPreference(accessPoint,
getActivity());
- if (showAppIcons) {
- preference.showAppIcon();
- }
getPreferenceScreen().addPreference(preference);
accessPoint.setListener(this);