Allow overriding enterprise related strings in Launcher
Test: manual
Bug: 188414133
Bug: 211422509
Bug: 188410712
Change-Id: I75858cdcf2057e7c270da5893cd9a90c6753f182
diff --git a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
index 0e534f4..8424564 100644
--- a/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
+++ b/quickstep/src/com/android/launcher3/model/QuickstepModelDelegate.java
@@ -15,6 +15,20 @@
*/
package com.android.launcher3.model;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_PERSONAL_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_PERSONAL_TAB_ACCESSIBILITY;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_WORK_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.ALL_APPS_WORK_TAB_ACCESSIBILITY;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.DISABLED_BY_ADMIN_MESSAGE;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WIDGETS_PERSONAL_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WIDGETS_WORK_TAB;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_FOLDER_NAME;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_EDU;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_EDU_ACCEPT;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_ENABLE_BUTTON;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_PAUSED_DESCRIPTION;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_PAUSED_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Launcher.WORK_PROFILE_PAUSE_BUTTON;
import static android.text.format.DateUtils.DAY_IN_MILLIS;
import static android.text.format.DateUtils.formatElapsedTime;
@@ -32,6 +46,7 @@
import static java.util.stream.Collectors.toCollection;
import android.app.StatsManager;
+import android.app.admin.DevicePolicyManager;
import android.app.prediction.AppPredictionContext;
import android.app.prediction.AppPredictionManager;
import android.app.prediction.AppPredictor;
@@ -136,6 +151,42 @@
}
@Override
+ @WorkerThread
+ public void loadStringCache(StringCache cache) {
+ cache.loadDefaultStrings(mContext);
+
+ cache.workProfileEdu = getEnterpriseString(WORK_PROFILE_EDU, cache.workProfileEdu);
+ cache.workProfileEduAccept = getEnterpriseString(
+ WORK_PROFILE_EDU_ACCEPT, cache.workProfileEduAccept);
+ cache.workProfilePausedTitle = getEnterpriseString(
+ WORK_PROFILE_PAUSED_TITLE, cache.workProfilePausedTitle);
+ cache.workProfilePausedDescription = getEnterpriseString(
+ WORK_PROFILE_PAUSED_DESCRIPTION, cache.workProfilePausedDescription);
+ cache.workProfilePauseButton = getEnterpriseString(
+ WORK_PROFILE_PAUSE_BUTTON, cache.workProfilePauseButton);
+ cache.workProfileEnableButton = getEnterpriseString(
+ WORK_PROFILE_ENABLE_BUTTON, cache.workProfileEnableButton);
+ cache.allAppsWorkTab = getEnterpriseString(ALL_APPS_WORK_TAB, cache.allAppsWorkTab);
+ cache.allAppsPersonalTab = getEnterpriseString(
+ ALL_APPS_PERSONAL_TAB, cache.allAppsPersonalTab);
+ cache.allAppsWorkTabAccessibility = getEnterpriseString(
+ ALL_APPS_WORK_TAB_ACCESSIBILITY, cache.allAppsWorkTabAccessibility);
+ cache.allAppsPersonalTabAccessibility = getEnterpriseString(
+ ALL_APPS_PERSONAL_TAB_ACCESSIBILITY, cache.allAppsPersonalTabAccessibility);
+ cache.workFolderName = getEnterpriseString(WORK_FOLDER_NAME, cache.workFolderName);
+ cache.widgetsWorkTab = getEnterpriseString(WIDGETS_WORK_TAB, cache.widgetsWorkTab);
+ cache.widgetsPersonalTab = getEnterpriseString(
+ WIDGETS_PERSONAL_TAB, cache.widgetsPersonalTab);
+ cache.disabledByAdminMessage = getEnterpriseString(
+ DISABLED_BY_ADMIN_MESSAGE, cache.disabledByAdminMessage);
+ }
+
+ private String getEnterpriseString(String updatableStringId, String defaultString) {
+ DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
+ return dpm.getString(updatableStringId, () -> defaultString);
+ }
+
+ @Override
public void workspaceLoadComplete() {
super.workspaceLoadComplete();
recreatePredictors();
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 84c4783..59c40cc 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -149,6 +149,7 @@
import com.android.launcher3.model.ItemInstallQueue;
import com.android.launcher3.model.ModelUtils;
import com.android.launcher3.model.ModelWriter;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
@@ -379,6 +380,8 @@
protected InstanceId mAllAppsSessionLogId;
private LauncherState mPrevLauncherState;
+ private StringCache mStringCache;
+
@Override
@TargetApi(Build.VERSION_CODES.S)
protected void onCreate(Bundle savedInstanceState) {
@@ -2872,6 +2875,16 @@
mPopupDataProvider.setAllWidgets(allWidgets);
}
+ @Override
+ public void bindStringCache(StringCache cache) {
+ mStringCache = cache;
+ }
+
+ @Override
+ public StringCache getStringCache() {
+ return mStringCache;
+ }
+
/**
* @param packageUser if null, refreshes all widgets and shortcuts, otherwise only
* refreshes the widgets and shortcuts associated with the given package/user
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index c1f0e06..1253863 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -38,10 +38,10 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
+import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -57,6 +57,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.keyboard.FocusedItemDecorator;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
@@ -298,27 +299,34 @@
/** Description of the container view based on its current state. */
public String getDescription() {
- @StringRes int descriptionRes;
+ StringCache cache = mActivityContext.getStringCache();
if (mUsingTabs) {
- descriptionRes =
- mViewPager.getNextPage() == 0
- ? R.string.all_apps_button_personal_label
- : R.string.all_apps_button_work_label;
- } else {
- descriptionRes = R.string.all_apps_button_label;
+ if (cache != null) {
+ return isPersonalTab()
+ ? cache.allAppsPersonalTabAccessibility
+ : cache.allAppsWorkTabAccessibility;
+ } else {
+ return isPersonalTab()
+ ? getContext().getString(R.string.all_apps_button_personal_label)
+ : getContext().getString(R.string.all_apps_button_work_label);
+ }
}
- return getContext().getString(descriptionRes);
+ return getContext().getString(R.string.all_apps_button_label);
}
/** The current recycler view visible in the container. */
public AllAppsRecyclerView getActiveRecyclerView() {
- if (!mUsingTabs || mViewPager.getNextPage() == 0) {
+ if (!mUsingTabs || isPersonalTab()) {
return mAH.get(AdapterHolder.MAIN).mRecyclerView;
} else {
return mAH.get(AdapterHolder.WORK).mRecyclerView;
}
}
+ protected boolean isPersonalTab() {
+ return mViewPager.getNextPage() == 0;
+ }
+
public LayoutInflater getLayoutInflater() {
return LayoutInflater.from(getContext());
}
@@ -440,6 +448,7 @@
.log(LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB);
}
});
+ setDeviceManagementResources();
onActivePageChanged(mViewPager.getNextPage());
} else {
mAH.get(AdapterHolder.MAIN).setup(findViewById(R.id.apps_list_view), null);
@@ -451,6 +460,16 @@
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
}
+ private void setDeviceManagementResources() {
+ if (mActivityContext.getStringCache() != null) {
+ Button personalTab = findViewById(R.id.tab_personal);
+ personalTab.setText(mActivityContext.getStringCache().allAppsPersonalTab);
+
+ Button workTab = findViewById(R.id.tab_work);
+ workTab.setText(mActivityContext.getStringCache().allAppsWorkTab);
+ }
+ }
+
protected boolean showTabs() {
return mHasWorkApps;
}
diff --git a/src/com/android/launcher3/allapps/WorkAdapterProvider.java b/src/com/android/launcher3/allapps/WorkAdapterProvider.java
index 331320d..f52a21f 100644
--- a/src/com/android/launcher3/allapps/WorkAdapterProvider.java
+++ b/src/com/android/launcher3/allapps/WorkAdapterProvider.java
@@ -17,9 +17,14 @@
import android.content.SharedPreferences;
import android.view.LayoutInflater;
+import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
import com.android.launcher3.R;
+import com.android.launcher3.model.StringCache;
+import com.android.launcher3.views.ActivityContext;
import java.util.ArrayList;
@@ -35,9 +40,11 @@
@WorkProfileManager.WorkProfileState
private int mState;
+ private ActivityContext mActivityContext;
private SharedPreferences mPreferences;
- WorkAdapterProvider(SharedPreferences prefs) {
+ WorkAdapterProvider(ActivityContext activityContext, SharedPreferences prefs) {
+ mActivityContext = activityContext;
mPreferences = prefs;
}
@@ -53,7 +60,40 @@
ViewGroup parent, int viewType) {
int viewId = viewType == VIEW_TYPE_WORK_DISABLED_CARD ? R.layout.work_apps_paused
: R.layout.work_apps_edu;
- return new AllAppsGridAdapter.ViewHolder(layoutInflater.inflate(viewId, parent, false));
+ View view = layoutInflater.inflate(viewId, parent, false);
+ setDeviceManagementResources(view, viewType);
+ return new AllAppsGridAdapter.ViewHolder(view);
+ }
+
+ private void setDeviceManagementResources(View view, int viewType) {
+ StringCache cache = mActivityContext.getStringCache();
+ if (cache == null) {
+ return;
+ }
+ if (viewType == VIEW_TYPE_WORK_DISABLED_CARD) {
+ setWorkProfilePausedResources(view, cache);
+ } else {
+ setWorkProfileEduResources(view, cache);
+ }
+ }
+
+ private void setWorkProfilePausedResources(View view, StringCache cache) {
+ TextView title = view.findViewById(R.id.work_apps_paused_title);
+ title.setText(cache.workProfilePausedTitle);
+
+ TextView body = view.findViewById(R.id.work_apps_paused_content);
+ body.setText(cache.workProfilePausedDescription);
+
+ TextView button = view.findViewById(R.id.enable_work_apps);
+ button.setText(cache.workProfileEnableButton);
+ }
+
+ private void setWorkProfileEduResources(View view, StringCache cache) {
+ TextView title = view.findViewById(R.id.work_apps_paused_title);
+ title.setText(cache.workProfileEdu);
+
+ Button button = view.findViewById(R.id.action_btn);
+ button.setText(cache.workProfileEduAccept);
}
/**
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index 4598690..733577e 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -30,6 +30,7 @@
import com.android.launcher3.Insettable;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.KeyboardInsetAnimationCallback;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
@@ -72,8 +73,14 @@
new KeyboardInsetAnimationCallback(this);
setWindowInsetsAnimationCallback(keyboardInsetAnimationCallback);
}
- DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
+ ActivityContext activityContext = ActivityContext.lookupContext(getContext());
+ DeviceProfile grid = activityContext.getDeviceProfile();
setInsets(grid.getInsets());
+
+ StringCache cache = activityContext.getStringCache();
+ if (cache != null) {
+ setText(cache.workProfilePauseButton);
+ }
}
@Override
@@ -120,7 +127,6 @@
}
}
-
private void updateVisibility() {
clearAnimation();
if (mWorkEnabled && mOnWorkTab) {
diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java
index bcaf1f4..9d1b04e 100644
--- a/src/com/android/launcher3/allapps/WorkProfileManager.java
+++ b/src/com/android/launcher3/allapps/WorkProfileManager.java
@@ -79,7 +79,7 @@
SharedPreferences preferences) {
mUserManager = userManager;
mAllApps = allApps;
- mAdapterProvider = new WorkAdapterProvider(preferences);
+ mAdapterProvider = new WorkAdapterProvider(allApps.mActivityContext, preferences);
mMatcher = mAllApps.mPersonalMatcher.negate();
}
diff --git a/src/com/android/launcher3/folder/FolderNameProvider.java b/src/com/android/launcher3/folder/FolderNameProvider.java
index 3d3a96d..7793b16 100644
--- a/src/com/android/launcher3/folder/FolderNameProvider.java
+++ b/src/com/android/launcher3/folder/FolderNameProvider.java
@@ -27,12 +27,14 @@
import com.android.launcher3.model.AllAppsList;
import com.android.launcher3.model.BaseModelUpdateTask;
import com.android.launcher3.model.BgDataModel;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.IntSparseArrayMap;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.ResourceBasedOverride;
+import com.android.launcher3.views.ActivityContext;
import java.util.ArrayList;
import java.util.Arrays;
@@ -101,13 +103,16 @@
if (DEBUG) {
Log.d(TAG, "getSuggestedFolderName:" + nameInfos.toString());
}
+
// If all the icons are from work profile,
// Then, suggest "Work" as the folder name
Set<UserHandle> users = workspaceItemInfos.stream().map(w -> w.user)
.collect(Collectors.toSet());
if (users.size() == 1 && !users.contains(Process.myUserHandle())) {
- setAsLastSuggestion(nameInfos,
- context.getResources().getString(R.string.work_folder_name));
+ StringCache cache = ActivityContext.lookupContext(context).getStringCache();
+ String workFolderName = cache != null
+ ? cache.workFolderName : context.getString(R.string.work_folder_name);
+ setAsLastSuggestion(nameInfos, workFolderName);
}
// If all the icons are from same package (e.g., main icon, shortcut, shortcut)
diff --git a/src/com/android/launcher3/model/BaseLoaderResults.java b/src/com/android/launcher3/model/BaseLoaderResults.java
index d270cc5..5b278ab 100644
--- a/src/com/android/launcher3/model/BaseLoaderResults.java
+++ b/src/com/android/launcher3/model/BaseLoaderResults.java
@@ -226,6 +226,8 @@
MODEL_EXECUTOR.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
c.onInitialBindComplete(currentScreenIds, pendingTasks);
}, mUiExecutor);
+
+ mCallbacks.bindStringCache(mBgDataModel.stringCache.clone());
}
private void bindWorkspaceItems(
diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java
index 84612de..866d18a 100644
--- a/src/com/android/launcher3/model/BgDataModel.java
+++ b/src/com/android/launcher3/model/BgDataModel.java
@@ -114,6 +114,11 @@
public final WidgetsModel widgetsModel = new WidgetsModel();
/**
+ * Cache for strings used in launcher
+ */
+ public final StringCache stringCache = new StringCache();
+
+ /**
* Id when the model was last bound
*/
public int lastBindId = 0;
@@ -505,5 +510,10 @@
default void bindExtraContainerItems(FixedContainerItems item) { }
default void bindAllApplications(AppInfo[] apps, int flags) { }
+
+ /**
+ * Binds the cache of string resources
+ */
+ default void bindStringCache(StringCache cache) { }
}
}
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index 2a0f9a6..b9fa21d 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -857,6 +857,9 @@
// Load delegate items
mModelDelegate.loadItems(mUserManagerState, shortcutKeyToPinnedShortcuts);
+ // Load string cache
+ mModelDelegate.loadStringCache(mBgDataModel.stringCache);
+
// Break early if we've stopped loading
if (mStopped) {
mBgDataModel.clear();
diff --git a/src/com/android/launcher3/model/ModelDelegate.java b/src/com/android/launcher3/model/ModelDelegate.java
index 765141a..60ca63b 100644
--- a/src/com/android/launcher3/model/ModelDelegate.java
+++ b/src/com/android/launcher3/model/ModelDelegate.java
@@ -48,9 +48,11 @@
delegate.mAppsList = appsList;
delegate.mDataModel = dataModel;
delegate.mIsPrimaryInstance = isPrimaryInstance;
+ delegate.mContext = context;
return delegate;
}
+ protected Context mContext;
protected LauncherAppState mApp;
protected AllAppsList mAppsList;
protected BgDataModel mDataModel;
@@ -76,6 +78,15 @@
public void loadItems(UserManagerState ums, Map<ShortcutKey, ShortcutInfo> pinnedShortcuts) { }
/**
+ * Load String cache
+ */
+ @WorkerThread
+ public void loadStringCache(StringCache cache) {
+ cache.loadDefaultStrings(mContext);
+ }
+
+
+ /**
* Called during loader after workspace loading is complete
*/
@WorkerThread
diff --git a/src/com/android/launcher3/model/StringCache.java b/src/com/android/launcher3/model/StringCache.java
new file mode 100644
index 0000000..11d3e70
--- /dev/null
+++ b/src/com/android/launcher3/model/StringCache.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+package com.android.launcher3.model;
+
+import android.content.Context;
+
+import com.android.launcher3.R;
+
+/**
+ *
+ * Cache for some of the string used in Launcher.
+ */
+public class StringCache {
+
+ /**
+ * User on-boarding title for work profile apps.
+ */
+ public String workProfileEdu;
+
+ /**
+ * Action label to finish work profile edu.
+ */
+ public String workProfileEduAccept;
+
+ /**
+ * Title shown when user opens work apps tab while work profile is paused.
+ */
+ public String workProfilePausedTitle;
+
+ /**
+ * Description shown when user opens work apps tab while work profile is paused.
+ */
+ public String workProfilePausedDescription;
+
+ /**
+ * Shown on the button to pause work profile.
+ */
+ public String workProfilePauseButton;
+
+ /**
+ * Shown on the button to enable work profile.
+ */
+ public String workProfileEnableButton;
+
+ /**
+ * Label on launcher tab to indicate work apps.
+ */
+ public String allAppsWorkTab;
+
+ /**
+ * Label on launcher tab to indicate personal apps.
+ */
+ public String allAppsPersonalTab;
+
+ /**
+ * Accessibility description for launcher tab to indicate work apps.
+ */
+ public String allAppsWorkTabAccessibility;
+
+ /**
+ * Accessibility description for launcher tab to indicate personal apps.
+ */
+ public String allAppsPersonalTabAccessibility;
+
+ /**
+ * Work folder name.
+ */
+ public String workFolderName;
+
+ /**
+ * Label on widget tab to indicate work app widgets.
+ */
+ public String widgetsWorkTab;
+
+ /**
+ * Label on widget tab to indicate personal app widgets.
+ */
+ public String widgetsPersonalTab;
+
+ /**
+ * Message shown when a feature is disabled by the admin (e.g. changing wallpaper).
+ */
+ public String disabledByAdminMessage;
+
+ /**
+ * Sets the default values for the strings.
+ */
+ public void loadDefaultStrings(Context context) {
+ workProfileEdu = context.getString(R.string.work_profile_edu_work_apps);
+ workProfileEduAccept = context.getString(R.string.work_profile_edu_accept);
+ workProfilePausedTitle = context.getString(R.string.work_apps_paused_title);
+ workProfilePausedDescription = context.getString(R.string.work_apps_paused_body);
+ workProfilePauseButton = context.getString(R.string.work_apps_pause_btn_text);
+ workProfileEnableButton = context.getString(R.string.work_apps_enable_btn_text);
+ allAppsWorkTab = context.getString(R.string.all_apps_work_tab);
+ allAppsPersonalTab = context.getString(R.string.all_apps_personal_tab);
+ allAppsWorkTabAccessibility = context.getString(R.string.all_apps_button_work_label);
+ allAppsPersonalTabAccessibility = context.getString(
+ R.string.all_apps_button_personal_label);
+ workFolderName = context.getString(R.string.work_folder_name);
+ widgetsWorkTab = context.getString(R.string.widgets_full_sheet_work_tab);
+ widgetsPersonalTab = context.getString(R.string.widgets_full_sheet_personal_tab);
+ disabledByAdminMessage = context.getString(R.string.msg_disabled_by_admin);
+ }
+
+ @Override
+ public StringCache clone() {
+ StringCache clone = new StringCache();
+ clone.workProfileEdu = this.workProfileEdu;
+ clone.workProfileEduAccept = this.workProfileEduAccept;
+ clone.workProfilePausedTitle = this.workProfilePausedTitle;
+ clone.workProfilePausedDescription = this.workProfilePausedDescription;
+ clone.workProfilePauseButton = this.workProfilePauseButton;
+ clone.workProfileEnableButton = this.workProfileEnableButton;
+ clone.allAppsWorkTab = this.allAppsWorkTab;
+ clone.allAppsPersonalTab = this.allAppsPersonalTab;
+ clone.allAppsWorkTabAccessibility = this.allAppsWorkTabAccessibility;
+ clone.allAppsPersonalTabAccessibility = this.allAppsPersonalTabAccessibility;
+ clone.workFolderName = this.workFolderName;
+ clone.widgetsWorkTab = this.widgetsWorkTab;
+ clone.widgetsPersonalTab = this.widgetsPersonalTab;
+ clone.disabledByAdminMessage = this.disabledByAdminMessage;
+ return clone;
+ }
+}
diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
index cba0655..73aa296 100644
--- a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
+++ b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
@@ -32,6 +32,7 @@
import com.android.launcher3.R;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
import com.android.launcher3.model.BgDataModel;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
@@ -60,6 +61,8 @@
private boolean mAppDrawerShown = false;
+ private StringCache mStringCache;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -227,6 +230,16 @@
PopupContainerWithArrow.dismissInvalidPopup(this);
}
+ @Override
+ public StringCache getStringCache() {
+ return mStringCache;
+ }
+
+ @Override
+ public void bindStringCache(StringCache cache) {
+ mStringCache = cache;
+ }
+
public PopupDataProvider getPopupDataProvider() {
return mPopupDataProvider;
}
diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java
index 8b48bae..a318363 100644
--- a/src/com/android/launcher3/views/ActivityContext.java
+++ b/src/com/android/launcher3/views/ActivityContext.java
@@ -31,6 +31,7 @@
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.logging.StatsLogManager;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.util.ViewCache;
@@ -173,4 +174,9 @@
default PopupDataProvider getPopupDataProvider() {
return null;
}
+
+ @Nullable
+ default StringCache getStringCache() {
+ return null;
+ }
}
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index fc8b4b7..95bce31 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -240,7 +240,10 @@
private static boolean startWallpaperPicker(View v) {
Launcher launcher = Launcher.getLauncher(v.getContext());
if (!Utilities.isWallpaperAllowed(launcher)) {
- Toast.makeText(launcher, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
+ String message = launcher.getStringCache() != null
+ ? launcher.getStringCache().disabledByAdminMessage
+ : launcher.getString(R.string.msg_disabled_by_admin);
+ Toast.makeText(launcher, message, Toast.LENGTH_SHORT).show();
return false;
}
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
index 894c4c9..daa8fb7 100644
--- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
+++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java
@@ -41,6 +41,7 @@
import android.view.WindowInsets;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
+import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.Nullable;
@@ -199,6 +200,7 @@
findViewById(R.id.tab_work)
.setOnClickListener((View view) -> mViewPager.snapToPage(1));
mAdapters.get(AdapterHolder.WORK).setup(findViewById(R.id.work_widgets_list_view));
+ setDeviceManagementResources();
} else {
mViewPager = null;
}
@@ -220,6 +222,16 @@
setUpEducationViewsIfNeeded();
}
+ private void setDeviceManagementResources() {
+ if (mActivityContext.getStringCache() != null) {
+ Button personalTab = findViewById(R.id.tab_personal);
+ personalTab.setText(mActivityContext.getStringCache().widgetsPersonalTab);
+
+ Button workTab = findViewById(R.id.tab_work);
+ workTab.setText(mActivityContext.getStringCache().widgetsWorkTab);
+ }
+ }
+
@Override
public void onActivePageChanged(int currentActivePage) {
AdapterHolder currentAdapterHolder = mAdapters.get(currentActivePage);
diff --git a/tests/src/com/android/launcher3/folder/FolderNameProviderTest.java b/tests/src/com/android/launcher3/folder/FolderNameProviderTest.java
index 23e6235..9c15309 100644
--- a/tests/src/com/android/launcher3/folder/FolderNameProviderTest.java
+++ b/tests/src/com/android/launcher3/folder/FolderNameProviderTest.java
@@ -30,6 +30,7 @@
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.launcher3.util.ActivityContextWrapper;
import com.android.launcher3.util.Executors;
import org.junit.Before;
@@ -47,7 +48,7 @@
@Before
public void setUp() {
- mContext = getApplicationContext();
+ mContext = new ActivityContextWrapper(getApplicationContext());
mItem1 = new WorkspaceItemInfo(new AppInfo(
new ComponentName("a.b.c", "a.b.c/a.b.c.d"),
"title1",