Skip to content

Commit b1d4d4c

Browse files
committed
Use new preferences for managed profile policies.
Change-Id: I2241b15b7066907120b2003ef3b07d1db5f29f7c
1 parent 64766c0 commit b1d4d4c

File tree

2 files changed

+48
-69
lines changed

2 files changed

+48
-69
lines changed

app/src/main/java/com/afwsamples/testdpc/profilepolicy/ProfilePolicyManagementFragment.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,6 @@ public class ProfilePolicyManagementFragment extends BaseSearchablePolicyPrefere
8686

8787
private static final String ORGANIZATION_COLOR_ID = "organizationColor";
8888

89-
private static String[] MNC_PLUS_PREFERENCES = {
90-
DISABLE_BLUETOOTH_CONTACT_SHARING_KEY
91-
};
92-
93-
private static String[] NYC_PLUS_PREFERENCES = {
94-
DISABLE_CROSS_PROFILE_CONTACTS_SEARCH_KEY, SET_ORGANIZATION_COLOR_KEY,
95-
SET_ORGANIZATION_NAME_KEY
96-
};
97-
9889
private DevicePolicyManager mDevicePolicyManager;
9990
private ComponentName mAdminComponentName;
10091
private Preference mAddCrossProfileIntentFilterPreference;
@@ -133,7 +124,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
133124
REMOVE_CROSS_PROFILE_APP_WIDGETS_KEY);
134125
mRemoveCrossProfileAppWidgetsPreference.setOnPreferenceClickListener(this);
135126

136-
disableIncompatibleManagementOptionsByApiLevel();
137127
initSwitchPreferences();
138128
initializeOrganizationInfoPreferences();
139129
}
@@ -402,20 +392,4 @@ private void showToast(String msg) {
402392
}
403393
Toast.makeText(activity, msg, Toast.LENGTH_SHORT).show();
404394
}
405-
406-
private void disableIncompatibleManagementOptionsByApiLevel() {
407-
if (Util.isBeforeM()) {
408-
// The following options depend on MNC APIs.
409-
for (String preference : MNC_PLUS_PREFERENCES) {
410-
findPreference(preference).setEnabled(false);
411-
}
412-
}
413-
414-
if (Util.isBeforeN()) {
415-
// The following options depend on NYC APIs.
416-
for (String preference : NYC_PLUS_PREFERENCES) {
417-
findPreference(preference).setEnabled(false);
418-
}
419-
}
420-
}
421395
}
Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
Copyright (C) 2015 The Android Open Source Project
43
54
Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,56 +14,62 @@
1514
limitations under the License.
1615
-->
1716

18-
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
17+
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:testdpc="http://schemas.android.com/apk/res/com.afwsamples.testdpc">
1919

20-
<PreferenceCategory
21-
android:title="@string/organization_info">
22-
<Preference
23-
android:key="set_organization_color"
24-
android:title="@string/set_organization_color" />
25-
<EditTextPreference
26-
android:key="set_organization_name"
27-
android:title="@string/set_organization_name" />
20+
<PreferenceCategory android:title="@string/organization_info">
21+
<com.afwsamples.testdpc.common.preference.DpcPreference
22+
android:key="set_organization_color"
23+
android:title="@string/set_organization_color"
24+
testdpc:minSdkVersion="N" />
25+
<com.afwsamples.testdpc.common.preference.DpcEditTextPreference
26+
android:key="set_organization_name"
27+
android:title="@string/set_organization_name"
28+
testdpc:minSdkVersion="N" />
2829
</PreferenceCategory>
2930

30-
<PreferenceCategory
31-
android:title="@string/cross_profile_intents">
32-
<Preference
33-
android:title="@string/add_cross_profile_intents_title"
34-
android:key="add_cross_profile_intent_filter"/>
35-
<Preference
36-
android:title="@string/clear_cross_profile_intents"
37-
android:key="clear_cross_profile_intent_filters"/>
31+
<PreferenceCategory android:title="@string/cross_profile_intents">
32+
<com.afwsamples.testdpc.common.preference.DpcPreference
33+
android:key="add_cross_profile_intent_filter"
34+
android:title="@string/add_cross_profile_intents_title"
35+
testdpc:minSdkVersion="L" />
36+
<com.afwsamples.testdpc.common.preference.DpcPreference
37+
android:key="clear_cross_profile_intent_filters"
38+
android:title="@string/clear_cross_profile_intents"
39+
testdpc:minSdkVersion="L" />
3840
</PreferenceCategory>
3941

40-
<PreferenceCategory
41-
android:title="@string/cross_profile_widget_providers_title">
42-
<Preference
43-
android:key="add_cross_profile_app_widgets"
44-
android:title="@string/add_cross_profile_app_widget_providers"/>
45-
<Preference
46-
android:key="remove_cross_profile_app_widgets"
47-
android:title="@string/remove_cross_profile_app_widget_providers"/>
42+
<PreferenceCategory android:title="@string/cross_profile_widget_providers_title">
43+
<com.afwsamples.testdpc.common.preference.DpcPreference
44+
android:key="add_cross_profile_app_widgets"
45+
android:title="@string/add_cross_profile_app_widget_providers"
46+
testdpc:minSdkVersion="L" />
47+
<com.afwsamples.testdpc.common.preference.DpcPreference
48+
android:key="remove_cross_profile_app_widgets"
49+
android:title="@string/remove_cross_profile_app_widget_providers"
50+
testdpc:minSdkVersion="L" />
4851
</PreferenceCategory>
4952

50-
<PreferenceCategory
51-
android:title="@string/policies_title">
52-
<SwitchPreference
53-
android:key="disable_bluetooth_contact_sharing"
54-
android:title="@string/disable_bluetooth_contact_sharing"/>
55-
<SwitchPreference
56-
android:key="disable_cross_profile_caller_id"
57-
android:title="@string/disable_cross_profile_caller_id"/>
58-
<SwitchPreference
59-
android:key="disable_cross_profile_contacts_search"
60-
android:title="@string/disable_cross_profile_contacts_search"/>
53+
<PreferenceCategory android:title="@string/policies_title">
54+
<com.afwsamples.testdpc.common.preference.DpcSwitchPreference
55+
android:key="disable_bluetooth_contact_sharing"
56+
android:title="@string/disable_bluetooth_contact_sharing"
57+
testdpc:minSdkVersion="M" />
58+
<com.afwsamples.testdpc.common.preference.DpcSwitchPreference
59+
android:key="disable_cross_profile_caller_id"
60+
android:title="@string/disable_cross_profile_caller_id"
61+
testdpc:minSdkVersion="L" />
62+
<com.afwsamples.testdpc.common.preference.DpcSwitchPreference
63+
android:key="disable_cross_profile_contacts_search"
64+
android:title="@string/disable_cross_profile_contacts_search"
65+
testdpc:minSdkVersion="N" />
6166
</PreferenceCategory>
6267

63-
<PreferenceCategory
64-
android:title="@string/profile_management_title">
65-
<Preference
66-
android:key="remove_profile"
67-
android:title="@string/remove_managed_profile"/>
68+
<PreferenceCategory android:title="@string/profile_management_title">
69+
<com.afwsamples.testdpc.common.preference.DpcPreference
70+
android:key="remove_profile"
71+
android:title="@string/remove_managed_profile"
72+
testdpc:minSdkVersion="L" />
6873
</PreferenceCategory>
6974

7075
</PreferenceScreen>

0 commit comments

Comments
 (0)