Merge "Clean up device profile change listeners for AllApps." into udc-dev am: cdfdd444bc

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/22335494

Change-Id: Ic296dd4980cd7736cb39ff6dd0aa82829ba48ffd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Brian Isganitis
2023-03-31 18:55:26 +00:00
committed by Automerger Merge Worker
3 changed files with 31 additions and 3 deletions
@@ -76,7 +76,6 @@ public class PredictionRowView<T extends Context & ActivityContext>
mFocusHelper = new SimpleFocusIndicatorHelper(this); mFocusHelper = new SimpleFocusIndicatorHelper(this);
mActivityContext = ActivityContext.lookupContext(context); mActivityContext = ActivityContext.lookupContext(context);
mActivityContext.addOnDeviceProfileChangeListener(this);
mNumPredictedAppsPerRow = mActivityContext.getDeviceProfile().numShownAllAppsColumns; mNumPredictedAppsPerRow = mActivityContext.getDeviceProfile().numShownAllAppsColumns;
updateVisibility(); updateVisibility();
} }
@@ -84,6 +83,13 @@ public class PredictionRowView<T extends Context & ActivityContext>
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
mActivityContext.addOnDeviceProfileChangeListener(this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mActivityContext.removeOnDeviceProfileChangeListener(this);
} }
public void setup(FloatingHeaderView parent, FloatingHeaderRow[] rows, boolean tabsHidden) { public void setup(FloatingHeaderView parent, FloatingHeaderRow[] rows, boolean tabsHidden) {
@@ -112,12 +112,23 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
DeviceProfile dp = mActivityContext.getDeviceProfile(); DeviceProfile dp = mActivityContext.getDeviceProfile();
setShiftRange(dp.allAppsShiftRange); setShiftRange(dp.allAppsShiftRange);
mActivityContext.addOnDeviceProfileChangeListener(this);
setContentBackgroundWithParent( setContentBackgroundWithParent(
getContext().getDrawable(R.drawable.bg_rounded_corner_bottom_sheet), getContext().getDrawable(R.drawable.bg_rounded_corner_bottom_sheet),
mAppsView.getBottomSheetBackground()); mAppsView.getBottomSheetBackground());
} }
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mActivityContext.addOnDeviceProfileChangeListener(this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mActivityContext.removeOnDeviceProfileChangeListener(this);
}
@Override @Override
protected void onScaleProgressChanged() { protected void onScaleProgressChanged() {
super.onScaleProgressChanged(); super.onScaleProgressChanged();
@@ -192,7 +192,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
onAppsUpdated); onAppsUpdated);
} }
mAllAppsStore.addUpdateListener(onAppsUpdated); mAllAppsStore.addUpdateListener(onAppsUpdated);
mActivityContext.addOnDeviceProfileChangeListener(this);
// This is a focus listener that proxies focus from a view into the list view. This is to // This is a focus listener that proxies focus from a view into the list view. This is to
// work around the search box from getting first focus and showing the cursor. // work around the search box from getting first focus and showing the cursor.
@@ -263,6 +262,18 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
mSearchUiManager.initializeSearch(this); mSearchUiManager.initializeSearch(this);
} }
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mActivityContext.addOnDeviceProfileChangeListener(this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
mActivityContext.removeOnDeviceProfileChangeListener(this);
}
public SearchUiManager getSearchUiManager() { public SearchUiManager getSearchUiManager() {
return mSearchUiManager; return mSearchUiManager;
} }