Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ec7b98c authored by Kevin's avatar Kevin
Browse files

Add icon recents view for Go

Add a specific view for Go's icon recents. We also add a few properties
for use in future refactors.

Bug: 114136250
Test: Build Launcher3GoIconRecents
Change-Id: I9852679256158344ab276d1c477f55b7dd2d6a52
parent c049c80e
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -14,6 +14,11 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.quickstep.views.IconRecentsView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <!-- TODO(114136250): Remove this temporary placeholder view for Go recents -->
    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
@@ -22,3 +27,4 @@
        android:gravity="center"
        android:text="Stub!"
        android:textSize="40sp"/>
</com.android.quickstep.views.IconRecentsView>
 No newline at end of file
+75 −0
Original line number Diff line number Diff line
/*
 * 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<IconRecentsView> TRANSLATION_Y_FACTOR =
            new FloatProperty<IconRecentsView>("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<IconRecentsView> CONTENT_ALPHA =
            new FloatProperty<IconRecentsView>("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());
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -67,6 +67,10 @@ public class LauncherRecentsView extends RecentsView<Launcher> {
                }
            };

    /**
     * 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;