Files
Lawnchair/src/com/android/launcher3/util/MultiTranslateDelegate.java
T
Liran Binyamin a833af316b Adjust the hotseat when the bubble bar becomes visible
When the bubble bar becomes visible the space between icons in the
hotseat is now adjusted. This change only does it when the QSB is
above the icons, but this will be changed in the future to be based
on the amount of space between the hotseat and the edge of the screen.

When the hotseat is adjusted, the new width is smaller by the size of
2 icons. The icons are then translated to be evenly spaced within the
boundaries of the new width.

Since the adjustment is only applied when the QSB is above the icons,
it is resized accordingly to the new width.

All visual updates currently snap to the new position, but will be animated
in a follow up.

Demo: https://recall.googleplex.com/projects/3391fc5c-599d-4827-b6f8-d2deb160aa99/sessions/fad1a5c5-e9cf-4586-92e4-1e92df3b002e

Bug: 280494203
Test: Manual (on tangor)
      - Set device to landscape
      - Make the bubble bar visible by adding a bubble
      - Rotate to portrait mode
      - Observe that the hotseat is adjusted
      - Rotate to landscape
      - Observe that the hotseat adjustment is removed
      - Rotate back to portrait
      - Observe that the hotseat is adjusted again
      - Dismiss the bubble to hide he bubble bar
      - Observe the hotseat adjustment is removed

Change-Id: I5b02a60b6cb301ffa2507a6d825c748a782cca18
2023-09-13 17:08:42 -04:00

82 lines
2.8 KiB
Java

/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.util;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import android.view.View;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
/**
* A utility class to split translation components for various workspace items
*/
public class MultiTranslateDelegate {
// offset related to reorder hint and bounce animations
public static final int INDEX_REORDER_BOUNCE_OFFSET = 0;
// offset related to previewing the new reordered position
public static final int INDEX_REORDER_PREVIEW_OFFSET = 1;
public static final int INDEX_MOVE_FROM_CENTER_ANIM = 2;
// Specific for items in taskbar (icons, folders, qsb)
public static final int INDEX_TASKBAR_ALIGNMENT_ANIM = 3;
public static final int INDEX_TASKBAR_REVEAL_ANIM = 4;
// Specific for widgets
public static final int INDEX_WIDGET_CENTERING = 3;
// Specific for hotseat items when adjusting for bubbles
public static final int INDEX_BUBBLE_ADJUSTMENT_ANIM = 3;
public static final int COUNT = 5;
private final MultiPropertyFactory<View> mTranslationX;
private final MultiPropertyFactory<View> mTranslationY;
public MultiTranslateDelegate(View target) {
this(target, COUNT, COUNT);
}
public MultiTranslateDelegate(View target, int countX, int countY) {
mTranslationX = new MultiPropertyFactory<>(target, VIEW_TRANSLATE_X, countX, Float::sum);
mTranslationY = new MultiPropertyFactory<>(target, VIEW_TRANSLATE_Y, countY, Float::sum);
}
/**
* Helper method to set both translations, x and y at a given index
*/
public void setTranslation(int index, float x, float y) {
getTranslationX(index).setValue(x);
getTranslationY(index).setValue(y);
}
/**
* Returns the translation x for the provided index
*/
public MultiProperty getTranslationX(int index) {
return mTranslationX.get(index);
}
/**
* Returns the translation y for the provided index
*/
public MultiProperty getTranslationY(int index) {
return mTranslationY.get(index);
}
}