Loading res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -7466,4 +7466,11 @@ <!-- [CHAR LIMIT=60] Name of dev option called demo mode --> <string name="demo_mode">Demo mode</string> <!-- [CHAR LIMIT=60] Title of work profile setting page --> <string name="managed_profile_settings_title">Work profile settings</string> <!-- [CHAR LIMIT=60] The preference title for enabling cross-profile remote contact search --> <string name="managed_profile_contact_search_title">Contact search</string> <!-- [CHAR LIMIT=NONE] The preference summary for enabling cross-profile remote contact search --> <string name="managed_profile_contact_search_summary">Allow contact searches by your organization to identify callers and contacts</string> </resources> res/xml/managed_profile_settings.xml 0 → 100644 +33 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" android:title="@string/managed_profile_settings_title"> <SwitchPreference android:key="work_mode" android:summary="@string/work_mode_summary" android:title="@string/work_mode_label"/> <com.android.settingslib.RestrictedSwitchPreference android:key="contacts_search" android:summary="@string/managed_profile_contact_search_summary" android:title="@string/managed_profile_contact_search_title" settings:useAdditionalSummary="true" /> </PreferenceScreen> No newline at end of file src/com/android/settings/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ public class Settings extends SettingsActivity { } public static class ScreenLockSuggestionActivity extends ChooseLockGeneric { /* empty */ } public static class WallpaperSettingsActivity extends SettingsActivity { /* empty */ } public static class ManagedProfileSettingsActivity extends SettingsActivity { /* empty */ } // Categories. public static class WirelessSettings extends SettingsActivity { /* empty */ } Loading src/com/android/settings/SettingsActivity.java +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard; import com.android.settings.accessibility.CaptionPropertiesFragment; import com.android.settings.accounts.AccountSettings; import com.android.settings.accounts.AccountSyncSettings; import com.android.settings.accounts.ManagedProfileSettings; import com.android.settings.applications.AdvancedAppSettings; import com.android.settings.applications.DrawOverlayDetails; import com.android.settings.applications.InstalledAppDetails; Loading Loading @@ -328,6 +329,7 @@ public class SettingsActivity extends SettingsDrawerActivity AdvancedAppSettings.class.getName(), WallpaperTypeSettings.class.getName(), VrListenerSettings.class.getName(), ManagedProfileSettings.class.getName(), }; Loading src/com/android/settings/accounts/AccountSettings.java +38 −59 Original line number Diff line number Diff line Loading @@ -39,9 +39,7 @@ import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.provider.SearchIndexableResource; import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; import android.support.v7.preference.Preference.OnPreferenceChangeListener; import android.support.v7.preference.Preference.OnPreferenceClickListener; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceScreen; Loading @@ -55,6 +53,7 @@ import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.settings.AccessiblePreferenceCategory; import com.android.settings.DimmableIconPreference; import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; import com.android.settings.search.BaseSearchIndexProvider; Loading Loading @@ -84,7 +83,7 @@ import static android.provider.Settings.EXTRA_AUTHORITIES; */ public class AccountSettings extends SettingsPreferenceFragment implements AuthenticatorHelper.OnAccountsUpdateListener, OnPreferenceClickListener, OnPreferenceChangeListener, Indexable { OnPreferenceClickListener, Indexable { public static final String TAG = "AccountSettings"; private static final String KEY_ACCOUNT = "account"; Loading Loading @@ -116,14 +115,14 @@ public class AccountSettings extends SettingsPreferenceFragment * The preference that displays the add account button. */ public DimmableIconPreference addAccountPreference; /** * The preference that displays the button to toggle work profile. */ public SwitchPreference workModeSwitch; /** * The preference that displays the button to remove the managed profile */ public Preference removeWorkProfilePreference; /** * The preference that displays managed profile settings. */ public Preference managedProfilePreference; /** * The {@link AuthenticatorHelper} that holds accounts data for this profile. */ Loading Loading @@ -239,23 +238,12 @@ public class AccountSettings extends SettingsPreferenceFragment ).show(); return true; } } return false; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // Check the preference final int count = mProfiles.size(); for (int i = 0; i < count; i++) { ProfileData profileData = mProfiles.valueAt(i); if (preference == profileData.workModeSwitch) { final int userId = profileData.userInfo.id; if ((boolean) newValue) { mUm.trySetQuietModeDisabled(userId, null); } else { mUm.setQuietModeEnabled(userId, true); } if (preference == profileData.managedProfilePreference) { Bundle arguments = new Bundle(); arguments.putParcelable(Intent.EXTRA_USER, profileData.userInfo.getUserHandle()); ((SettingsActivity) getActivity()).startPreferencePanel( ManagedProfileSettings.class.getName(), arguments, R.string.managed_profile_settings_title, null, null, 0); return true; } } Loading Loading @@ -314,10 +302,8 @@ public class AccountSettings extends SettingsPreferenceFragment profileData.preferenceGroup.setSummary(workGroupSummary); ((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription( getString(R.string.accessibility_category_work, workGroupSummary)); profileData.workModeSwitch = newWorkModeSwitchPreference(context); final UserHandle userHandle = profileData.userInfo.getUserHandle(); profileData.workModeSwitch.setChecked(!mUm.isQuietModeEnabled(userHandle)); profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context); profileData.managedProfilePreference = newManagedProfileSettings(); } else { profileData.preferenceGroup.setTitle(R.string.category_personal); ((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription( Loading Loading @@ -351,15 +337,6 @@ public class AccountSettings extends SettingsPreferenceFragment return preference; } private SwitchPreference newWorkModeSwitchPreference(Context context) { SwitchPreference preference = new SwitchPreference(getPrefContext()); preference.setTitle(R.string.work_mode_label); preference.setSummary(R.string.work_mode_summary); preference.setOnPreferenceChangeListener(this); preference.setOrder(ORDER_NEXT_TO_LAST); return preference; } private Preference newRemoveWorkProfilePreference(Context context) { Preference preference = new Preference(getPrefContext()); preference.setTitle(R.string.remove_managed_profile_label); Loading @@ -369,6 +346,16 @@ public class AccountSettings extends SettingsPreferenceFragment return preference; } private Preference newManagedProfileSettings() { Preference preference = new Preference(getPrefContext()); preference.setTitle(R.string.managed_profile_settings_title); preference.setIcon(R.drawable.ic_sysbar_quicksettings); preference.setOnPreferenceClickListener(this); preference.setOrder(ORDER_NEXT_TO_LAST); return preference; } private String getWorkGroupSummary(Context context, UserInfo userInfo) { PackageManager packageManager = context.getPackageManager(); ApplicationInfo adminApplicationInfo = Utils.getAdminApplicationInfo(context, userInfo.id); Loading Loading @@ -428,12 +415,12 @@ public class AccountSettings extends SettingsPreferenceFragment R.string.managed_profile_not_available_label); profileData.preferenceGroup.addPreference(mProfileNotAvailablePreference); } if (profileData.workModeSwitch != null) { profileData.preferenceGroup.addPreference(profileData.workModeSwitch); } if (profileData.removeWorkProfilePreference != null) { profileData.preferenceGroup.addPreference(profileData.removeWorkProfilePreference); } if (profileData.managedProfilePreference != null) { profileData.preferenceGroup.addPreference(profileData.managedProfilePreference); } } private ArrayList<AccountPreference> getAccountTypePreferences(AuthenticatorHelper helper, Loading Loading @@ -594,18 +581,6 @@ public class AccountSettings extends SettingsPreferenceFragment getActivity().invalidateOptionsMenu(); return; } if (action.equals(Intent.ACTION_MANAGED_PROFILE_AVAILABLE) || action.equals(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)) { // We assume there's only one managed profile, otherwise this needs to change. ProfileData profileData = mProfiles.valueAt(1); if (intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL) == profileData.userInfo.id) { profileData.workModeSwitch.setChecked( !mUm.isQuietModeEnabled(profileData.userInfo.getUserHandle())); } return; } Log.w(TAG, "Cannot handle received broadcast: " + intent.getAction()); } Loading @@ -614,8 +589,6 @@ public class AccountSettings extends SettingsPreferenceFragment IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); context.registerReceiver(this, intentFilter); listeningToManagedProfileEvents = true; } Loading Loading @@ -729,18 +702,24 @@ public class AccountSettings extends SettingsPreferenceFragment if (!RestrictedLockUtils.hasBaseUserRestriction(context, DISALLOW_MODIFY_ACCOUNTS, userInfo.id)) { SearchIndexableRaw data = new SearchIndexableRaw(context); data = new SearchIndexableRaw(context); data.title = res.getString(R.string.add_account_label); data.screenTitle = screenTitle; result.add(data); } if (userInfo.isManagedProfile()) { { SearchIndexableRaw data = new SearchIndexableRaw(context); data = new SearchIndexableRaw(context); data.title = res.getString(R.string.remove_managed_profile_label); data.screenTitle = screenTitle; result.add(data); } { SearchIndexableRaw data = new SearchIndexableRaw(context); data.title = res.getString(R.string.managed_profile_settings_title); data.screenTitle = screenTitle; result.add(data); } } } } return result; Loading Loading
res/values/strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -7466,4 +7466,11 @@ <!-- [CHAR LIMIT=60] Name of dev option called demo mode --> <string name="demo_mode">Demo mode</string> <!-- [CHAR LIMIT=60] Title of work profile setting page --> <string name="managed_profile_settings_title">Work profile settings</string> <!-- [CHAR LIMIT=60] The preference title for enabling cross-profile remote contact search --> <string name="managed_profile_contact_search_title">Contact search</string> <!-- [CHAR LIMIT=NONE] The preference summary for enabling cross-profile remote contact search --> <string name="managed_profile_contact_search_summary">Allow contact searches by your organization to identify callers and contacts</string> </resources>
res/xml/managed_profile_settings.xml 0 → 100644 +33 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- 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. --> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:settings="http://schemas.android.com/apk/res/com.android.settings" android:title="@string/managed_profile_settings_title"> <SwitchPreference android:key="work_mode" android:summary="@string/work_mode_summary" android:title="@string/work_mode_label"/> <com.android.settingslib.RestrictedSwitchPreference android:key="contacts_search" android:summary="@string/managed_profile_contact_search_summary" android:title="@string/managed_profile_contact_search_title" settings:useAdditionalSummary="true" /> </PreferenceScreen> No newline at end of file
src/com/android/settings/Settings.java +1 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ public class Settings extends SettingsActivity { } public static class ScreenLockSuggestionActivity extends ChooseLockGeneric { /* empty */ } public static class WallpaperSettingsActivity extends SettingsActivity { /* empty */ } public static class ManagedProfileSettingsActivity extends SettingsActivity { /* empty */ } // Categories. public static class WirelessSettings extends SettingsActivity { /* empty */ } Loading
src/com/android/settings/SettingsActivity.java +2 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard; import com.android.settings.accessibility.CaptionPropertiesFragment; import com.android.settings.accounts.AccountSettings; import com.android.settings.accounts.AccountSyncSettings; import com.android.settings.accounts.ManagedProfileSettings; import com.android.settings.applications.AdvancedAppSettings; import com.android.settings.applications.DrawOverlayDetails; import com.android.settings.applications.InstalledAppDetails; Loading Loading @@ -328,6 +329,7 @@ public class SettingsActivity extends SettingsDrawerActivity AdvancedAppSettings.class.getName(), WallpaperTypeSettings.class.getName(), VrListenerSettings.class.getName(), ManagedProfileSettings.class.getName(), }; Loading
src/com/android/settings/accounts/AccountSettings.java +38 −59 Original line number Diff line number Diff line Loading @@ -39,9 +39,7 @@ import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.provider.SearchIndexableResource; import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; import android.support.v7.preference.Preference.OnPreferenceChangeListener; import android.support.v7.preference.Preference.OnPreferenceClickListener; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceScreen; Loading @@ -55,6 +53,7 @@ import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.settings.AccessiblePreferenceCategory; import com.android.settings.DimmableIconPreference; import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; import com.android.settings.search.BaseSearchIndexProvider; Loading Loading @@ -84,7 +83,7 @@ import static android.provider.Settings.EXTRA_AUTHORITIES; */ public class AccountSettings extends SettingsPreferenceFragment implements AuthenticatorHelper.OnAccountsUpdateListener, OnPreferenceClickListener, OnPreferenceChangeListener, Indexable { OnPreferenceClickListener, Indexable { public static final String TAG = "AccountSettings"; private static final String KEY_ACCOUNT = "account"; Loading Loading @@ -116,14 +115,14 @@ public class AccountSettings extends SettingsPreferenceFragment * The preference that displays the add account button. */ public DimmableIconPreference addAccountPreference; /** * The preference that displays the button to toggle work profile. */ public SwitchPreference workModeSwitch; /** * The preference that displays the button to remove the managed profile */ public Preference removeWorkProfilePreference; /** * The preference that displays managed profile settings. */ public Preference managedProfilePreference; /** * The {@link AuthenticatorHelper} that holds accounts data for this profile. */ Loading Loading @@ -239,23 +238,12 @@ public class AccountSettings extends SettingsPreferenceFragment ).show(); return true; } } return false; } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { // Check the preference final int count = mProfiles.size(); for (int i = 0; i < count; i++) { ProfileData profileData = mProfiles.valueAt(i); if (preference == profileData.workModeSwitch) { final int userId = profileData.userInfo.id; if ((boolean) newValue) { mUm.trySetQuietModeDisabled(userId, null); } else { mUm.setQuietModeEnabled(userId, true); } if (preference == profileData.managedProfilePreference) { Bundle arguments = new Bundle(); arguments.putParcelable(Intent.EXTRA_USER, profileData.userInfo.getUserHandle()); ((SettingsActivity) getActivity()).startPreferencePanel( ManagedProfileSettings.class.getName(), arguments, R.string.managed_profile_settings_title, null, null, 0); return true; } } Loading Loading @@ -314,10 +302,8 @@ public class AccountSettings extends SettingsPreferenceFragment profileData.preferenceGroup.setSummary(workGroupSummary); ((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription( getString(R.string.accessibility_category_work, workGroupSummary)); profileData.workModeSwitch = newWorkModeSwitchPreference(context); final UserHandle userHandle = profileData.userInfo.getUserHandle(); profileData.workModeSwitch.setChecked(!mUm.isQuietModeEnabled(userHandle)); profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context); profileData.managedProfilePreference = newManagedProfileSettings(); } else { profileData.preferenceGroup.setTitle(R.string.category_personal); ((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription( Loading Loading @@ -351,15 +337,6 @@ public class AccountSettings extends SettingsPreferenceFragment return preference; } private SwitchPreference newWorkModeSwitchPreference(Context context) { SwitchPreference preference = new SwitchPreference(getPrefContext()); preference.setTitle(R.string.work_mode_label); preference.setSummary(R.string.work_mode_summary); preference.setOnPreferenceChangeListener(this); preference.setOrder(ORDER_NEXT_TO_LAST); return preference; } private Preference newRemoveWorkProfilePreference(Context context) { Preference preference = new Preference(getPrefContext()); preference.setTitle(R.string.remove_managed_profile_label); Loading @@ -369,6 +346,16 @@ public class AccountSettings extends SettingsPreferenceFragment return preference; } private Preference newManagedProfileSettings() { Preference preference = new Preference(getPrefContext()); preference.setTitle(R.string.managed_profile_settings_title); preference.setIcon(R.drawable.ic_sysbar_quicksettings); preference.setOnPreferenceClickListener(this); preference.setOrder(ORDER_NEXT_TO_LAST); return preference; } private String getWorkGroupSummary(Context context, UserInfo userInfo) { PackageManager packageManager = context.getPackageManager(); ApplicationInfo adminApplicationInfo = Utils.getAdminApplicationInfo(context, userInfo.id); Loading Loading @@ -428,12 +415,12 @@ public class AccountSettings extends SettingsPreferenceFragment R.string.managed_profile_not_available_label); profileData.preferenceGroup.addPreference(mProfileNotAvailablePreference); } if (profileData.workModeSwitch != null) { profileData.preferenceGroup.addPreference(profileData.workModeSwitch); } if (profileData.removeWorkProfilePreference != null) { profileData.preferenceGroup.addPreference(profileData.removeWorkProfilePreference); } if (profileData.managedProfilePreference != null) { profileData.preferenceGroup.addPreference(profileData.managedProfilePreference); } } private ArrayList<AccountPreference> getAccountTypePreferences(AuthenticatorHelper helper, Loading Loading @@ -594,18 +581,6 @@ public class AccountSettings extends SettingsPreferenceFragment getActivity().invalidateOptionsMenu(); return; } if (action.equals(Intent.ACTION_MANAGED_PROFILE_AVAILABLE) || action.equals(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)) { // We assume there's only one managed profile, otherwise this needs to change. ProfileData profileData = mProfiles.valueAt(1); if (intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL) == profileData.userInfo.id) { profileData.workModeSwitch.setChecked( !mUm.isQuietModeEnabled(profileData.userInfo.getUserHandle())); } return; } Log.w(TAG, "Cannot handle received broadcast: " + intent.getAction()); } Loading @@ -614,8 +589,6 @@ public class AccountSettings extends SettingsPreferenceFragment IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE); intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE); context.registerReceiver(this, intentFilter); listeningToManagedProfileEvents = true; } Loading Loading @@ -729,18 +702,24 @@ public class AccountSettings extends SettingsPreferenceFragment if (!RestrictedLockUtils.hasBaseUserRestriction(context, DISALLOW_MODIFY_ACCOUNTS, userInfo.id)) { SearchIndexableRaw data = new SearchIndexableRaw(context); data = new SearchIndexableRaw(context); data.title = res.getString(R.string.add_account_label); data.screenTitle = screenTitle; result.add(data); } if (userInfo.isManagedProfile()) { { SearchIndexableRaw data = new SearchIndexableRaw(context); data = new SearchIndexableRaw(context); data.title = res.getString(R.string.remove_managed_profile_label); data.screenTitle = screenTitle; result.add(data); } { SearchIndexableRaw data = new SearchIndexableRaw(context); data.title = res.getString(R.string.managed_profile_settings_title); data.screenTitle = screenTitle; result.add(data); } } } } return result; Loading