Merge "Badge managed WiFi networks" into mnc-dev
This commit is contained in:
@@ -207,7 +207,9 @@
|
|||||||
<integer name="bluetooth_name_length">32</integer>
|
<integer name="bluetooth_name_length">32</integer>
|
||||||
<dimen name="bluetooth_pairing_padding">20dp</dimen>
|
<dimen name="bluetooth_pairing_padding">20dp</dimen>
|
||||||
|
|
||||||
|
<!-- WiFi Preferences -->
|
||||||
<dimen name="wifi_divider_height">1px</dimen>
|
<dimen name="wifi_divider_height">1px</dimen>
|
||||||
|
<dimen name="wifi_preference_badge_padding">8dip</dimen>
|
||||||
|
|
||||||
<!-- Color picker -->
|
<!-- Color picker -->
|
||||||
<dimen name="color_swatch_size">16dp</dimen>
|
<dimen name="color_swatch_size">16dp</dimen>
|
||||||
|
@@ -18,9 +18,12 @@ package com.android.settings.wifi;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.StateListDrawable;
|
import android.graphics.drawable.StateListDrawable;
|
||||||
|
import android.net.wifi.WifiConfiguration;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.wifi.AccessPoint;
|
import com.android.settingslib.wifi.AccessPoint;
|
||||||
|
|
||||||
@@ -33,6 +36,7 @@ public class AccessPointPreference extends Preference {
|
|||||||
|
|
||||||
private static int[] wifi_signal_attributes = { R.attr.wifi_signal };
|
private static int[] wifi_signal_attributes = { R.attr.wifi_signal };
|
||||||
|
|
||||||
|
private TextView mTitleView;
|
||||||
private TextView mSummaryView;
|
private TextView mSummaryView;
|
||||||
private boolean showSummary = true;
|
private boolean showSummary = true;
|
||||||
private boolean mForSavedNetworks = false;
|
private boolean mForSavedNetworks = false;
|
||||||
@@ -56,9 +60,12 @@ public class AccessPointPreference extends Preference {
|
|||||||
super.onBindView(view);
|
super.onBindView(view);
|
||||||
updateIcon(mAccessPoint.getLevel(), getContext());
|
updateIcon(mAccessPoint.getLevel(), getContext());
|
||||||
|
|
||||||
|
mTitleView = (TextView) view.findViewById(com.android.internal.R.id.title);
|
||||||
|
|
||||||
mSummaryView = (TextView) view.findViewById(com.android.internal.R.id.summary);
|
mSummaryView = (TextView) view.findViewById(com.android.internal.R.id.summary);
|
||||||
mSummaryView.setVisibility(showSummary ? View.VISIBLE : View.GONE);
|
mSummaryView.setVisibility(showSummary ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
updateBadge(getContext());
|
||||||
notifyChanged();
|
notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +101,27 @@ public class AccessPointPreference extends Preference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateBadge(Context context) {
|
||||||
|
if (mTitleView != null) {
|
||||||
|
WifiConfiguration config = mAccessPoint.getConfig();
|
||||||
|
if (config == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Fetch badge (may be null)
|
||||||
|
UserHandle creatorUser = new UserHandle(UserHandle.getUserId(config.creatorUid));
|
||||||
|
Drawable badge =
|
||||||
|
context.getPackageManager().getUserBadgeForDensity(creatorUser, 0 /* dpi */);
|
||||||
|
|
||||||
|
// Distance from the end of the title at which this AP's user badge should sit.
|
||||||
|
final int badgePadding = context.getResources()
|
||||||
|
.getDimensionPixelSize(R.dimen.wifi_preference_badge_padding);
|
||||||
|
|
||||||
|
// Attach to the end of the title view
|
||||||
|
mTitleView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, badge, null);
|
||||||
|
mTitleView.setCompoundDrawablePadding(badgePadding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows or Hides the Summary of an AccessPoint.
|
* Shows or Hides the Summary of an AccessPoint.
|
||||||
*
|
*
|
||||||
@@ -117,6 +145,7 @@ public class AccessPointPreference extends Preference {
|
|||||||
|
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
updateIcon(mAccessPoint.getLevel(), context);
|
updateIcon(mAccessPoint.getLevel(), context);
|
||||||
|
updateBadge(context);
|
||||||
|
|
||||||
// Force new summary
|
// Force new summary
|
||||||
setSummary(null);
|
setSummary(null);
|
||||||
|
Reference in New Issue
Block a user