Merge "Add offsetTranslationX for the AddDesktopButton" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
e801cd88e1
@@ -21,7 +21,9 @@ import android.graphics.drawable.ShapeDrawable
|
||||
import android.graphics.drawable.shapes.RoundRectShape
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ImageButton
|
||||
import com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.MultiPropertyFactory
|
||||
|
||||
/**
|
||||
* Button for supporting multiple desktop sessions. The button will be next to the first TaskView
|
||||
@@ -30,6 +32,29 @@ import com.android.launcher3.R
|
||||
class AddDesktopButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
ImageButton(context, attrs) {
|
||||
|
||||
private enum class TranslationX {
|
||||
GRID,
|
||||
OFFSET,
|
||||
}
|
||||
|
||||
private val multiTranslationX =
|
||||
MultiPropertyFactory(this, VIEW_TRANSLATE_X, TranslationX.entries.size) { a: Float, b: Float
|
||||
->
|
||||
a + b
|
||||
}
|
||||
|
||||
var gridTranslationX
|
||||
get() = multiTranslationX[TranslationX.GRID.ordinal].value
|
||||
set(value) {
|
||||
multiTranslationX[TranslationX.GRID.ordinal].value = value
|
||||
}
|
||||
|
||||
var offsetTranslationX
|
||||
get() = multiTranslationX[TranslationX.OFFSET.ordinal].value
|
||||
set(value) {
|
||||
multiTranslationX[TranslationX.OFFSET.ordinal].value = value
|
||||
}
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
|
||||
|
||||
@@ -3467,7 +3467,7 @@ public abstract class RecentsView<
|
||||
// `mAddDesktopButton`, shift `mAddDesktopButton` to accommodate.
|
||||
translationX += largeTaskWidthAndSpacing;
|
||||
}
|
||||
mAddDesktopButton.setTranslationX(translationX);
|
||||
mAddDesktopButton.setGridTranslationX(translationX);
|
||||
}
|
||||
|
||||
final TaskView runningTask = getRunningTaskView();
|
||||
@@ -4973,8 +4973,8 @@ public abstract class RecentsView<
|
||||
} else if (child instanceof ClearAllButton) {
|
||||
getPagedOrientationHandler().getPrimaryViewTranslate().set(child,
|
||||
totalTranslationX);
|
||||
} else {
|
||||
// TODO(b/389209581): Handle the page offsets update of the 'mAddDesktopButton'.
|
||||
} else if (child instanceof AddDesktopButton addDesktopButton) {
|
||||
addDesktopButton.setOffsetTranslationX(totalTranslationX);
|
||||
}
|
||||
if (mEnableDrawingLiveTile && i == getRunningTaskIndex()) {
|
||||
runActionOnRemoteHandles(
|
||||
@@ -6157,7 +6157,7 @@ public abstract class RecentsView<
|
||||
if (addDesktopButtonIndex != -1 && addDesktopButtonIndex < outPageScrolls.length) {
|
||||
outPageScrolls[addDesktopButtonIndex] =
|
||||
newPageScrolls[addDesktopButtonIndex] + Math.round(
|
||||
mAddDesktopButton.getTranslationX());
|
||||
mAddDesktopButton.getGridTranslationX());
|
||||
}
|
||||
|
||||
int lastTaskScroll = getLastTaskScroll(clearAllScroll, clearAllWidth);
|
||||
|
||||
Reference in New Issue
Block a user