mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 15:56:49 +00:00
Fix custom buttons with translated string
The reason why the buttons aren't being updated with the translated string is because the cache the views get the string from is not updated/loaded with the new language.
Rather, the update happens after the view has been inflated. With this change, when the string cache updates in bindStringCache(), we update the UI right then.
bug: 280958663
bug: 288442609
test: Manual
Change-Id: I7a49ee401d5a5f3268cfaef1abee8153e913a8ce
(cherry picked from commit 076dcdfd54)
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
package com.android.launcher3.allapps;
|
||||
|
||||
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_DISABLED_CARD;
|
||||
import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_EDU_CARD;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_COUNT;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB;
|
||||
@@ -77,6 +79,7 @@ import com.android.launcher3.keyboard.FocusedItemDecorator;
|
||||
import com.android.launcher3.model.StringCache;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.util.Executors;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
@@ -1110,6 +1113,30 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
|
||||
return view.getGlobalVisibleRect(new Rect());
|
||||
}
|
||||
|
||||
/** Called in Launcher#bindStringCache() to update the UI when cache is updated. */
|
||||
public void updateWorkUI() {
|
||||
setDeviceManagementResources();
|
||||
if (mWorkManager.getWorkModeSwitch() != null) {
|
||||
mWorkManager.getWorkModeSwitch().updateStringFromCache();
|
||||
}
|
||||
inflateWorkCardsIfNeeded();
|
||||
}
|
||||
|
||||
private void inflateWorkCardsIfNeeded() {
|
||||
AllAppsRecyclerView workRV = mAH.get(AdapterHolder.WORK).mRecyclerView;
|
||||
if (workRV != null) {
|
||||
for (int i = 0; i < workRV.getChildCount(); i++) {
|
||||
View currentView = workRV.getChildAt(i);
|
||||
int currentItemViewType = workRV.getChildViewHolder(currentView).getItemViewType();
|
||||
if (currentItemViewType == VIEW_TYPE_WORK_EDU_CARD) {
|
||||
((WorkEduCard) currentView).updateStringFromCache();
|
||||
} else if (currentItemViewType == VIEW_TYPE_WORK_DISABLED_CARD) {
|
||||
((WorkPausedCard) currentView).updateStringFromCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public boolean isPersonalTabVisible() {
|
||||
return isDescendantViewVisible(R.id.tab_personal);
|
||||
|
||||
Reference in New Issue
Block a user