Snap for 8139379 from 9f0d54ebe3 to sc-qpr3-release

Change-Id: I9373153d6e534cdc5d1e5b37b46b682c7bb37c87
This commit is contained in:
Android Build Coastguard Worker
2022-02-02 00:07:30 +00:00
8 changed files with 37 additions and 12 deletions
@@ -90,11 +90,12 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
private static final String WINDOW_TITLE = "Taskbar";
private final DeviceProfile mDeviceProfile;
private final LayoutInflater mLayoutInflater;
private final TaskbarDragLayer mDragLayer;
private final TaskbarControllers mControllers;
private DeviceProfile mDeviceProfile;
private final WindowManager mWindowManager;
private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
private final int mTaskbarHeightForIme;
@@ -125,10 +126,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
final Resources resources = getResources();
float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
mDeviceProfile.updateIconSize(1, resources);
float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
mDeviceProfile.updateIconSize(iconScale, resources);
updateIconSize(resources);
mTaskbarHeightForIme = resources.getDimensionPixelSize(R.dimen.taskbar_ime_size);
@@ -211,6 +209,19 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
mWindowManager.addView(mDragLayer, mWindowLayoutParams);
}
/** Updates the Device profile instance to the latest representation of the screen. */
public void updateDeviceProfile(DeviceProfile dp) {
mDeviceProfile = dp;
updateIconSize(getResources());
}
private void updateIconSize(Resources resources) {
float taskbarIconSize = resources.getDimension(R.dimen.taskbar_icon_size);
mDeviceProfile.updateIconSize(1, resources);
float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
mDeviceProfile.updateIconSize(iconScale, resources);
}
public void onConfigurationChanged(@Config int configChanges) {
mControllers.onConfigurationChanged(configChanges);
}
@@ -145,7 +145,7 @@ public class TaskbarDragController extends DragController<TaskbarActivityContext
PopupContainerWithArrow<TaskbarActivityContext> popupContainer =
mControllers.taskbarPopupController.showForIcon(btv);
if (popupContainer != null) {
dragOptions.preDragCondition = popupContainer.createPreDragCondition();
dragOptions.preDragCondition = popupContainer.createPreDragCondition(false);
}
}
@@ -110,6 +110,13 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen
} else {
// Config change might be handled without re-creating the taskbar
if (mTaskbarActivityContext != null) {
DeviceProfile dp = mUserUnlocked
? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext)
: null;
if (dp != null && dp.isTaskbarPresent) {
mTaskbarActivityContext.updateDeviceProfile(dp.copy(mContext));
}
mTaskbarActivityContext.onConfigurationChanged(configDiff);
}
}
@@ -35,6 +35,7 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.icu.text.MessageFormat;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
import android.util.Property;
@@ -785,7 +786,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
invalidate();
}
}
if (itemInfo.contentDescription != null) {
if (!TextUtils.isEmpty(itemInfo.contentDescription)) {
if (itemInfo.isDisabled()) {
setContentDescription(getContext().getString(R.string.disabled_app_label,
itemInfo.contentDescription));
+2 -1
View File
@@ -460,9 +460,10 @@ public final class Utilities {
* Trims the string, removing all whitespace at the beginning and end of the string.
* Non-breaking whitespaces are also removed.
*/
@NonNull
public static String trim(CharSequence s) {
if (s == null) {
return null;
return "";
}
// Just strip any sequence of whitespace or java space characters from the beginning and end
+1 -1
View File
@@ -1686,7 +1686,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
PopupContainerWithArrow<Launcher> popupContainer = PopupContainerWithArrow
.showForIcon((BubbleTextView) child);
if (popupContainer != null) {
dragOptions.preDragCondition = popupContainer.createPreDragCondition();
dragOptions.preDragCondition = popupContainer.createPreDragCondition(true);
}
}
@@ -202,8 +202,7 @@ public class LoaderCursor extends CursorWrapper {
* Returns the title or empty string
*/
private String getTitle() {
String title = getString(titleIndex);
return TextUtils.isEmpty(title) ? "" : Utilities.trim(title);
return Utilities.trim(getString(titleIndex));
}
/**
@@ -396,7 +396,7 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
* Current behavior:
* - Start the drag if the touch passes a certain distance from the original touch down.
*/
public DragOptions.PreDragCondition createPreDragCondition() {
public DragOptions.PreDragCondition createPreDragCondition(boolean updateIconUi) {
return new DragOptions.PreDragCondition() {
@Override
@@ -406,6 +406,9 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
@Override
public void onPreDragStart(DropTarget.DragObject dragObject) {
if (!updateIconUi) {
return;
}
if (mIsAboveIcon) {
// Hide only the icon, keep the text visible.
mOriginalIcon.setIconVisible(false);
@@ -418,6 +421,9 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext>
@Override
public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) {
if (!updateIconUi) {
return;
}
mOriginalIcon.setIconVisible(true);
if (dragStarted) {
// Make sure we keep the original icon hidden while it is being dragged.