diff --git a/go/quickstep/res/layout/icon_recents_root_view.xml b/go/quickstep/res/layout/icon_recents_root_view.xml index 122fadf245..82d58909e5 100644 --- a/go/quickstep/res/layout/icon_recents_root_view.xml +++ b/go/quickstep/res/layout/icon_recents_root_view.xml @@ -14,11 +14,17 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + android:gravity="center"> + + + \ No newline at end of file diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java new file mode 100644 index 0000000000..e4741e9d50 --- /dev/null +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2019 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.quickstep.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.FloatProperty; +import android.view.ViewDebug; +import android.widget.FrameLayout; + +/** + * Root view for the icon recents view. + */ +public final class IconRecentsView extends FrameLayout { + + public static final FloatProperty TRANSLATION_Y_FACTOR = + new FloatProperty("translationYFactor") { + + @Override + public void setValue(IconRecentsView view, float v) { + view.setTranslationYFactor(v); + } + + @Override + public Float get(IconRecentsView view) { + return view.mTranslationYFactor; + } + }; + + public static final FloatProperty CONTENT_ALPHA = + new FloatProperty("contentAlpha") { + @Override + public void setValue(IconRecentsView view, float v) { + ALPHA.set(view, v); + } + + @Override + public Float get(IconRecentsView view) { + return ALPHA.get(view); + } + }; + + /** + * A ratio representing the view's relative placement within its padded space. For example, 0 + * is top aligned and 0.5 is centered vertically. + */ + @ViewDebug.ExportedProperty(category = "launcher") + private float mTranslationYFactor; + + public IconRecentsView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void setTranslationYFactor(float translationFactor) { + mTranslationYFactor = translationFactor; + setTranslationY(computeTranslationYForFactor(mTranslationYFactor)); + } + + private float computeTranslationYForFactor(float translationYFactor) { + return translationYFactor * (getPaddingBottom() - getPaddingTop()); + } +} diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 7389d65a65..722c721f9e 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -67,6 +67,10 @@ public class LauncherRecentsView extends RecentsView { } }; + /** + * A ratio representing the view's relative placement within its padded space. For example, 0 + * is top aligned and 0.5 is centered vertically. + */ @ViewDebug.ExportedProperty(category = "launcher") private float mTranslationYFactor;