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
This commit is contained in:
Kevin 2019-01-17 12:40:52 -08:00
parent c049c80e41
commit 5ec7b98c66
3 changed files with 90 additions and 5 deletions

View File

@ -14,11 +14,17 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- TODO(114136250): Remove this temporary placeholder view for Go recents -->
<TextView
<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"
android:text="Stub!"
android:textSize="40sp"/>
android:gravity="center">
<!-- TODO(114136250): Remove this temporary placeholder view for Go recents -->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Stub!"
android:textSize="40sp"/>
</com.android.quickstep.views.IconRecentsView>

View File

@ -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<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());
}
}

View File

@ -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;