Handle configuration changes in floating rotation button

Update resources in floating rotation button
when configurations such as screen density, screen size,
current locale have changed.

Bug: 200103245
Test: change display size, locale, fold/unfold
 -> check that floating rotation button resources
    are updated
Change-Id: Ia69f4f8b393a686012e286a1e39822650c562d52
This commit is contained in:
Nick Chameyev 2021-11-26 11:38:28 +00:00
parent 0b7ed895e7
commit 71eed5ca35
4 changed files with 23 additions and 0 deletions

View File

@ -38,6 +38,7 @@ import android.animation.ObjectAnimator;
import android.annotation.DrawableRes;
import android.annotation.IdRes;
import android.annotation.LayoutRes;
import android.content.pm.ActivityInfo.Config;
import android.content.res.ColorStateList;
import android.graphics.Rect;
import android.graphics.Region;
@ -451,6 +452,12 @@ public class NavbarButtonsViewController {
return mFloatingRotationButtonBounds.contains((int) ev.getX(), (int) ev.getY());
}
public void onConfigurationChanged(@Config int configChanges) {
if (mFloatingRotationButton != null) {
mFloatingRotationButton.onConfigurationChanged(configChanges);
}
}
public void onDestroy() {
mPropertyHolders.clear();
mControllers.rotationButtonController.unregisterListeners();

View File

@ -31,6 +31,7 @@ import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo.Config;
import android.content.pm.LauncherApps;
import android.graphics.Insets;
import android.graphics.PixelFormat;
@ -207,6 +208,10 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
Log.d(TASKBAR_WINDOW_CRASH, "Adding taskbar window");
}
public void onConfigurationChanged(@Config int configChanges) {
mControllers.onConfigurationChanged(configChanges);
}
public boolean isThreeButtonNav() {
return mNavMode == Mode.THREE_BUTTONS;
}

View File

@ -15,6 +15,8 @@
*/
package com.android.launcher3.taskbar;
import android.content.pm.ActivityInfo.Config;
import androidx.annotation.NonNull;
import com.android.systemui.shared.rotation.RotationButtonController;
@ -94,6 +96,10 @@ public class TaskbarControllers {
taskbarEduController.init(this);
}
public void onConfigurationChanged(@Config int configChanges) {
navbarButtonsViewController.onConfigurationChanged(configChanges);
}
/**
* Cleans up all controllers.
*/

View File

@ -107,6 +107,11 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen
if ((configDiff & configsRequiringRecreate) != 0) {
// Color has changed, recreate taskbar to reload background color & icons.
recreateTaskbar();
} else {
// Config change might be handled without re-creating the taskbar
if (mTaskbarActivityContext != null) {
mTaskbarActivityContext.onConfigurationChanged(configDiff);
}
}
mOldConfig = newConfig;
}