@Override
public Drawable getUserBadgeForDensity(UserHandle user, int density) {
+ return getManagedProfileIconForDensity(user, density,
+ com.android.internal.R.drawable.ic_corp_badge);
+ }
+
+ @Override
+ public Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density) {
+ return getManagedProfileIconForDensity(user, density,
+ com.android.internal.R.drawable.ic_corp_badge_no_background);
+ }
+
+ private Drawable getManagedProfileIconForDensity(UserHandle user, int density,
+ int drawableId) {
UserInfo userInfo = getUserIfProfile(user.getIdentifier());
if (userInfo != null && userInfo.isManagedProfile()) {
if (density <= 0) {
density = mContext.getResources().getDisplayMetrics().densityDpi;
}
- return Resources.getSystem().getDrawableForDensity(
- com.android.internal.R.drawable.ic_corp_badge, density);
+ return Resources.getSystem().getDrawableForDensity(drawableId, density);
}
return null;
}
private Drawable getProfileBadgeDrawable() {
// Note: This assumes that the current user can read the profile badge of the
// originating user.
- return mContext.getPackageManager().getUserBadgeForDensity(
+ return mContext.getPackageManager().getUserBadgeForDensityNoBackground(
new UserHandle(mContext.getUserId()), 0);
}
/**
* If the target user is a managed profile of the calling user or the caller
+ * is itself a managed profile, then this returns a drawable to use as a small
+ * icon to include in a view to distinguish it from the original icon. This version
+ * doesn't have background protection and should be used over a light background instead of
+ * a badge.
+ *
+ * @param user The target user.
+ * @param density The optional desired density for the badge as per
+ * {@link android.util.DisplayMetrics#densityDpi}. If not provided
+ * the density of the current display is used.
+ * @return the drawable or null if no drawable is required.
+ * @hide
+ */
+ public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density);
+
+ /**
+ * If the target user is a managed profile of the calling user or the caller
* is itself a managed profile, then this returns a copy of the label with
* badging for accessibility services like talkback. E.g. passing in "Email"
* and it might return "Work Email" for Email in the work profile.
--- /dev/null
+<!--
+Copyright (C) 2016 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="24.0dp"
+ android:height="24.0dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:pathData="M20.801,5.981L17.13,5.98l0.001,-1.471l-2.053,-2.055L8.969,2.453L6.915,4.506L6.914,5.977L3.203,5.976c-1.216,0.0 -2.189,0.983 -2.189,2.199L1.0,12.406c0.0,1.216 0.983,2.2 2.199,2.2L10.0,14.608l0.0,-1.644l0.291,0.0l3.351,0.0l0.291,0.0l0.0,1.645l6.863,0.002c1.216,0.0 2.2,-0.983 2.2,-2.199L23.0,8.181C23.0,6.965 22.017,5.981 20.801,5.981zM15.076,5.979L8.968,5.978l0.001,-1.471l6.108,0.001L15.076,5.979z"
+ android:fillColor="#FF5722"/>
+ <path
+ android:pathData="M13.911,16.646L9.978,16.646L9.978,15.48L1.673,15.48l0.0,4.105c0.0,1.216 0.959,2.2 2.175,2.2l16.13,0.004c1.216,0.0 2.203,-0.983 2.203,-2.199l0.0,-4.11l-8.27,0.0L13.910999,16.646z"
+ android:fillColor="#FF5722"/>
+ <path
+ android:pathData="M23.657,6.55 h4.72 v1.137 h-4.72z"
+ android:fillColor="#00000000"/>
+</vector>
\ No newline at end of file
android:layout_height="@dimen/notification_badge_size"
android:layout_gravity="center"
android:layout_marginStart="4dp"
+ android:paddingTop="1dp"
android:scaleType="fitCenter"
android:visibility="gone"
android:contentDescription="@string/notification_work_profile_content_description"
<dimen name="notification_large_icon_circle_padding">11dp</dimen>
<!-- Size of the profile badge for notifications -->
- <dimen name="notification_badge_size">16dp</dimen>
+ <dimen name="notification_badge_size">12dp</dimen>
<!-- Keyguard dimensions -->
<!-- TEMP -->
<java-symbol type="drawable" name="ic_corp_badge" />
<java-symbol type="drawable" name="ic_corp_badge_off" />
<java-symbol type="drawable" name="ic_corp_icon_badge" />
+ <java-symbol type="drawable" name="ic_corp_badge_no_background" />
<java-symbol type="drawable" name="ic_corp_icon" />
<java-symbol type="drawable" name="ic_corp_statusbar_icon" />
<java-symbol type="drawable" name="emulator_circular_window_overlay" />
throw new UnsupportedOperationException();
}
+ /** @hide */
+ @Override
+ public Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density) {
+ throw new UnsupportedOperationException();
+ }
+
@Override
public CharSequence getUserBadgedLabel(CharSequence label, UserHandle user) {
throw new UnsupportedOperationException();