Add MDM app name under "Work" in Accounts section of Settings.
Bug: 20024761 Change-Id: I3fe3fd6be8a2d96b36c402ea9bde8cc782797262
This commit is contained in:
40
res/layout/work_profile_category.xml
Normal file
40
res/layout/work_profile_category.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2015 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Layout used for "Work" preference group in Accounts. -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dip"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
|
android:paddingTop="16dip"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="@android:style/TextAppearance.Material.Body2"
|
||||||
|
android:textColor="?android:attr/colorAccent" />
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/summary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:singleLine="true" />
|
||||||
|
</LinearLayout>
|
@@ -29,6 +29,8 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -269,8 +271,14 @@ public class AccountSettings extends SettingsPreferenceFragment
|
|||||||
profileData.userInfo = userInfo;
|
profileData.userInfo = userInfo;
|
||||||
if (addCategory) {
|
if (addCategory) {
|
||||||
profileData.preferenceGroup = new PreferenceCategory(context);
|
profileData.preferenceGroup = new PreferenceCategory(context);
|
||||||
profileData.preferenceGroup.setTitle(userInfo.isManagedProfile()
|
if (userInfo.isManagedProfile()) {
|
||||||
? R.string.category_work : R.string.category_personal);
|
profileData.preferenceGroup.setLayoutResource(R.layout.work_profile_category);
|
||||||
|
profileData.preferenceGroup.setTitle(R.string.category_work);
|
||||||
|
profileData.preferenceGroup.setSummary(getWorkGroupSummary(context, userInfo));
|
||||||
|
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
|
||||||
|
} else {
|
||||||
|
profileData.preferenceGroup.setTitle(R.string.category_personal);
|
||||||
|
}
|
||||||
parent.addPreference(profileData.preferenceGroup);
|
parent.addPreference(profileData.preferenceGroup);
|
||||||
} else {
|
} else {
|
||||||
profileData.preferenceGroup = parent;
|
profileData.preferenceGroup = parent;
|
||||||
@@ -282,9 +290,6 @@ public class AccountSettings extends SettingsPreferenceFragment
|
|||||||
profileData.addAccountPreference = newAddAccountPreference(context);
|
profileData.addAccountPreference = newAddAccountPreference(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (userInfo.isManagedProfile()) {
|
|
||||||
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
|
|
||||||
}
|
|
||||||
mProfiles.put(userInfo.id, profileData);
|
mProfiles.put(userInfo.id, profileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,6 +311,16 @@ public class AccountSettings extends SettingsPreferenceFragment
|
|||||||
return preference;
|
return preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getWorkGroupSummary(Context context, UserInfo userInfo) {
|
||||||
|
PackageManager packageManager = context.getPackageManager();
|
||||||
|
ApplicationInfo adminApplicationInfo = Utils.getAdminApplicationInfo(context, userInfo.id);
|
||||||
|
if (adminApplicationInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CharSequence appLabel = packageManager.getApplicationLabel(adminApplicationInfo);
|
||||||
|
return getString(R.string.managing_admin, appLabel);
|
||||||
|
}
|
||||||
|
|
||||||
private void cleanUpPreferences() {
|
private void cleanUpPreferences() {
|
||||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
if (preferenceScreen != null) {
|
if (preferenceScreen != null) {
|
||||||
|
Reference in New Issue
Block a user