Merging MultiValueAlpha with MultiPropertyFactory

Bug: 246644619
Test: Presubmi
Change-Id: Id5abc5f3169544656f1139ae17ca59e34ac65dac
This commit is contained in:
Sunny Goyal
2022-09-13 14:40:48 -07:00
parent b9bced07c2
commit d859060860
23 changed files with 253 additions and 313 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.android.launcher3.allapps;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT;
import static com.android.launcher3.LauncherState.NORMAL;
@@ -42,6 +43,7 @@ import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.views.ScrimView;
@@ -82,8 +84,7 @@ public class AllAppsTransitionController
if (controller.mIsTablet) {
return controller.mAppsView.getActiveRecyclerView().getTranslationY();
} else {
return controller.getAppsViewPullbackTranslationY().get(
controller.mAppsView);
return controller.getAppsViewPullbackTranslationY().getValue();
}
}
@@ -92,8 +93,7 @@ public class AllAppsTransitionController
if (controller.mIsTablet) {
controller.mAppsView.getActiveRecyclerView().setTranslationY(translation);
} else {
controller.getAppsViewPullbackTranslationY().set(controller.mAppsView,
translation);
controller.getAppsViewPullbackTranslationY().setValue(translation);
}
}
};
@@ -140,10 +140,8 @@ public class AllAppsTransitionController
private ScrimView mScrimView;
private final MultiPropertyFactory<View>
mAppsViewTranslationYPropertyFactory = new MultiPropertyFactory<>(
"appsViewTranslationY", View.TRANSLATION_Y, Float::sum);
private MultiValueAlpha mAppsViewAlpha;
private MultiPropertyFactory<View> mAppsViewTranslationY;
private boolean mIsTablet;
@@ -184,7 +182,7 @@ public class AllAppsTransitionController
*/
public void setProgress(float progress) {
mProgress = progress;
getAppsViewProgressTranslationY().set(mAppsView, mProgress * mShiftRange);
getAppsViewProgressTranslationY().setValue(mProgress * mShiftRange);
mLauncher.onAllAppsTransition(1 - progress);
}
@@ -192,20 +190,20 @@ public class AllAppsTransitionController
return mProgress;
}
private FloatProperty<View> getAppsViewProgressTranslationY() {
return mAppsViewTranslationYPropertyFactory.get(INDEX_APPS_VIEW_PROGRESS);
private MultiProperty getAppsViewProgressTranslationY() {
return mAppsViewTranslationY.get(INDEX_APPS_VIEW_PROGRESS);
}
private FloatProperty<View> getAppsViewPullbackTranslationY() {
return mAppsViewTranslationYPropertyFactory.get(INDEX_APPS_VIEW_PULLBACK);
private MultiProperty getAppsViewPullbackTranslationY() {
return mAppsViewTranslationY.get(INDEX_APPS_VIEW_PULLBACK);
}
private MultiValueAlpha.AlphaProperty getAppsViewProgressAlpha() {
return mAppsViewAlpha.getProperty(INDEX_APPS_VIEW_PROGRESS);
private MultiProperty getAppsViewProgressAlpha() {
return mAppsViewAlpha.get(INDEX_APPS_VIEW_PROGRESS);
}
private MultiValueAlpha.AlphaProperty getAppsViewPullbackAlpha() {
return mAppsViewAlpha.getProperty(INDEX_APPS_VIEW_PULLBACK);
private MultiProperty getAppsViewPullbackAlpha() {
return mAppsViewAlpha.get(INDEX_APPS_VIEW_PULLBACK);
}
/**
@@ -283,7 +281,7 @@ public class AllAppsTransitionController
boolean hasAllAppsContent = (visibleElements & ALL_APPS_CONTENT) != 0;
Interpolator allAppsFade = config.getInterpolator(ANIM_ALL_APPS_FADE, LINEAR);
setter.setFloat(getAppsViewProgressAlpha(), MultiValueAlpha.VALUE,
setter.setFloat(getAppsViewProgressAlpha(), MultiPropertyFactory.MULTI_PROPERTY_VALUE,
hasAllAppsContent ? 1 : 0, allAppsFade);
boolean shouldProtectHeader =
@@ -302,8 +300,11 @@ public class AllAppsTransitionController
mScrimView = scrimView;
mAppsView = appsView;
mAppsView.setScrimView(scrimView);
mAppsViewAlpha = new MultiValueAlpha(mAppsView, APPS_VIEW_INDEX_COUNT);
mAppsViewAlpha.setUpdateVisibility(true);
mAppsViewTranslationY = new MultiPropertyFactory<>(
mAppsView, VIEW_TRANSLATE_Y, APPS_VIEW_INDEX_COUNT, Float::sum);
}
/**