Skip to content

Commit 312b5ec

Browse files
author
Sudheer Shanka
committed
Avoid initializing preferences if they are disabled.
Bug: 27372049 Change-Id: I5b95ee4d1ea8625a4a987ac3f0278b5e95ed62cd
1 parent a93517f commit 312b5ec

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,20 @@ public void onColorSelected(int colorValue, String id) {
233233

234234
private void initializeOrganizationInfoPreferences() {
235235
mSetOrganizationColorPreference = findPreference(SET_ORGANIZATION_COLOR_KEY);
236-
mSetOrganizationColorPreference.setOnPreferenceClickListener(this);
237236
mSetOrganizationNamePreference = findPreference(SET_ORGANIZATION_NAME_KEY);
238-
mSetOrganizationNamePreference.setOnPreferenceChangeListener(this);
239237

240-
final int colorValue = mDevicePolicyManager.getOrganizationColor(mAdminComponentName);
241-
mSetOrganizationColorPreference.setSummary(
242-
String.format(ColorPicker.COLOR_STRING_FORMATTER, colorValue));
238+
if (mSetOrganizationColorPreference.isEnabled()) {
239+
mSetOrganizationColorPreference.setOnPreferenceClickListener(this);
240+
final int colorValue = mDevicePolicyManager.getOrganizationColor(mAdminComponentName);
241+
mSetOrganizationColorPreference.setSummary(
242+
String.format(ColorPicker.COLOR_STRING_FORMATTER, colorValue));
243+
}
244+
245+
if (mSetOrganizationNamePreference.isEnabled()) {
246+
mSetOrganizationNamePreference.setOnPreferenceChangeListener(this);
247+
final String name = mDevicePolicyManager.getOrganizationName(mAdminComponentName);
248+
mSetOrganizationNamePreference.setSummary(name);
249+
}
243250
}
244251

245252
private void showAddCrossProfileIntentFilterFragment() {
@@ -275,13 +282,21 @@ private void reloadBluetoothContactSharing() {
275282
}
276283

277284
private void reloadCrossProfileCallerIdDisableUi() {
285+
if (!mDisableCrossProfileCallerIdSwitchPreference.isEnabled()) {
286+
return;
287+
}
288+
278289
boolean isCrossProfileCallerIdDisabled = mDevicePolicyManager
279290
.getCrossProfileCallerIdDisabled(mAdminComponentName);
280291
mDisableCrossProfileCallerIdSwitchPreference.setChecked(isCrossProfileCallerIdDisabled);
281292
}
282293

283294

284295
private void reloadCrossProfileContactsSearchDisableUi() {
296+
if (!mDisableCrossProfileContactsSearchSwitchPreference.isEnabled()) {
297+
return;
298+
}
299+
285300
boolean isCrossProfileContactsSearchDisabled = mDevicePolicyManager
286301
.getCrossProfileContactsSearchDisabled(mAdminComponentName);
287302
mDisableCrossProfileContactsSearchSwitchPreference.setChecked(

0 commit comments

Comments
 (0)