Allow overriding enterprise related strings in Launcher

Test: manual
Bug: 188414133
Bug: 211422509
Bug: 188410712
Change-Id: I75858cdcf2057e7c270da5893cd9a90c6753f182
This commit is contained in:
kholoud mohamed
2021-12-20 16:47:38 +00:00
parent 1d502c295a
commit c76b2035aa
17 changed files with 353 additions and 19 deletions
@@ -17,9 +17,14 @@ package com.android.launcher3.allapps;
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 @@ public class WorkAdapterProvider extends BaseAdapterProvider {
@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 @@ public class WorkAdapterProvider extends BaseAdapterProvider {
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);
}
/**