Update label accordingly when work mode is changed

Also, updates the work related strings accordingly.

Fix: 71987096

Change-Id: Iedbf6ee04f3a165a392efdf2bd351817997817ca
This commit is contained in:
Tony Mak committed 2018-01-16 21:33:56 +00:00
1 parent 000e0a1480
commit b5950bbd6c
7 files changed
+40 -22

No files matched your search

-1
View File
@@ -73,7 +73,6 @@
android:lines="1"
android:minHeight="24dp"
android:paddingStart="12dp"
android:text="@string/managed_by_your_organisation"
android:textColor="?android:attr/textColorHint"
android:textSize="13sp"/>
+9 -6
View File
@@ -324,13 +324,16 @@
<!-- Label of tab to indicate work apps -->
<string name="all_apps_work_tab">Work</string>
<!-- Label of the work mode toggle -->
<!-- This string is in the work profile tab when a user has All Apps open on their phone. This is a label for a toggle to turn the work profile on and off. "Work profile" means a separate profile on a user's phone that's specifically for their work apps and managed by their company. "Work" is used as an adjective.-->
<string name="work_profile_toggle_label">Work profile</string>
<!-- Title in bottom user education view in work tab -->
<!-- Title of an overlay in All Apps. This overlay is letting a user know about their work profile, which is managed by their employer. "Work apps" are apps in a user's work profile.-->
<string name="bottom_work_tab_user_education_title">Find work apps here</string>
<!-- Body text in bottom user education view in work tab -->
<string name="bottom_work_tab_user_education_body">Each work app has an orange badge, which means it\'s kept secure by your organization. Work apps can be moved to your Home Screen for easier access.</string>
<!-- Label in work tab to tell users that work profile is managed by their organisation. -->
<string name="managed_by_your_organisation">Managed by your organisation</string>
<!-- Text in an overlay in All Apps. This overlay is letting a user know about their work profile, which is managed by their employer.-->
<string name="bottom_work_tab_user_education_body">Each work app has an orange badge and is kept secure by your organization. Move apps to your Home screen for easier access.</string>
<!-- This string is in the work profile tab when a user has All Apps open on their phone. It describes the label of a toggle, "Work profile," as being managed by the user's employer.
"Organization" is used to represent a variety of businesses, non-profits, and educational institutions).-->
<string name="work_mode_on_label">Managed by your organization</string>
<!-- This string appears under a the label of a toggle in the work profile tab on a user's phone. It describes the status of the toggle, "Work profile," when it's turned off. "Work profile" means a separate profile on a user's phone that's speficially for their work apps and is managed by their company.-->
<string name="work_mode_off_label">Notifications and apps are off</string>
</resources>
@@ -41,6 +41,7 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AlphabeticalAppsList.AdapterItem;
import com.android.launcher3.anim.SpringAnimationHandler;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.discovery.AppDiscoveryAppInfo;
import com.android.launcher3.discovery.AppDiscoveryItemView;
@@ -377,6 +378,11 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
case VIEW_TYPE_WORK_TAB_FOOTER:
WorkModeSwitch workModeToggle = holder.itemView.findViewById(R.id.work_mode_toggle);
workModeToggle.refresh();
TextView managedByLabel = holder.itemView.findViewById(R.id.managed_by_label);
boolean anyProfileQuietModeEnabled = UserManagerCompat.getInstance(
managedByLabel.getContext()).isAnyProfileQuietModeEnabled();
managedByLabel.setText(anyProfileQuietModeEnabled
? R.string.work_mode_off_label : R.string.work_mode_on_label);
break;
}
if (mBindViewCallback != null) {
@@ -55,22 +55,9 @@ public class WorkModeSwitch extends Switch {
}
public void refresh() {
setCheckedInternal(!isAnyProfileQuietModeEnabled());
setEnabled(true);
}
private boolean isAnyProfileQuietModeEnabled() {
UserManagerCompat userManager = UserManagerCompat.getInstance(getContext());
List<UserHandle> userProfiles = userManager.getUserProfiles();
for (UserHandle userProfile : userProfiles) {
if (Process.myUserHandle().equals(userProfile)) {
continue;
}
if (userManager.isQuietModeEnabled(userProfile)) {
return true;
}
}
return false;
setCheckedInternal(!userManager.isAnyProfileQuietModeEnabled());
setEnabled(true);
}
private void trySetQuietModeEnabledToAllProfilesAsync(boolean enabled) {
@@ -64,4 +64,5 @@ public abstract class UserManagerCompat {
public abstract boolean isDemoUser();
public abstract boolean requestQuietModeEnabled(boolean enableQuietMode, UserHandle user);
public abstract boolean isAnyProfileQuietModeEnabled();
}
@@ -87,6 +87,11 @@ public class UserManagerCompatVL extends UserManagerCompat {
return false;
}
@Override
public boolean isAnyProfileQuietModeEnabled() {
return false;
}
@Override
public void enableAndResetCache() {
synchronized (this) {
@@ -19,8 +19,11 @@ package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
import java.util.List;
@TargetApi(Build.VERSION_CODES.N)
public class UserManagerCompatVN extends UserManagerCompatVM {
@@ -37,5 +40,19 @@ public class UserManagerCompatVN extends UserManagerCompatVM {
public boolean isUserUnlocked(UserHandle user) {
return mUserManager.isUserUnlocked(user);
}
@Override
public boolean isAnyProfileQuietModeEnabled() {
List<UserHandle> userProfiles = getUserProfiles();
for (UserHandle userProfile : userProfiles) {
if (Process.myUserHandle().equals(userProfile)) {
continue;
}
if (isQuietModeEnabled(userProfile)) {
return true;
}
}
return false;
}
}