summaryrefslogtreecommitdiffstats
path: root/go
diff options
context:
space:
mode:
authorKevin <kevhan@google.com>2019-04-23 14:31:23 -0700
committerKevin <kevhan@google.com>2019-04-23 15:35:05 -0700
commit483d2ddd4104f620ad3fdb7a139e43f05f5c4a5d (patch)
tree8195229bbe6cc1f1663c3834970b41540e40e9fd /go
parent6503757ac43c745bcf52e636f3a52c9fa568884c (diff)
downloadandroid_packages_apps_Trebuchet-483d2ddd4104f620ad3fdb7a139e43f05f5c4a5d.tar.gz
android_packages_apps_Trebuchet-483d2ddd4104f620ad3fdb7a139e43f05f5c4a5d.tar.bz2
android_packages_apps_Trebuchet-483d2ddd4104f620ad3fdb7a139e43f05f5c4a5d.zip
Use custom drawable for Recents Go thumbnails (2/2)
Hook up the thumbnail drawable created in the first CL to the task thumbnail so that the drawable automatically rotates and resizes based off the device orientation. Bug: 114136250 Bug: 131095241 Test: Go to app in landscape, go to recents, rotate => thumbnail rotates Change-Id: Ib58e45ab3e94aeb080e47b1d5b38c221acce5ef3
Diffstat (limited to 'go')
-rw-r--r--go/quickstep/src/com/android/quickstep/TaskAdapter.java2
-rw-r--r--go/quickstep/src/com/android/quickstep/TaskHolder.java7
-rw-r--r--go/quickstep/src/com/android/quickstep/views/IconRecentsView.java2
-rw-r--r--go/quickstep/src/com/android/quickstep/views/TaskItemView.java36
4 files changed, 30 insertions, 17 deletions
diff --git a/go/quickstep/src/com/android/quickstep/TaskAdapter.java b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
index 6f7562924..4f2b422e5 100644
--- a/go/quickstep/src/com/android/quickstep/TaskAdapter.java
+++ b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
@@ -146,7 +146,7 @@ public final class TaskAdapter extends Adapter<ViewHolder> {
});
mLoader.loadTaskThumbnail(task, () -> {
if (Objects.equals(Optional.of(task), taskHolder.getTask())) {
- taskHolder.getTaskItemView().setThumbnail(task.thumbnail.thumbnail);
+ taskHolder.getTaskItemView().setThumbnail(task.thumbnail);
}
});
break;
diff --git a/go/quickstep/src/com/android/quickstep/TaskHolder.java b/go/quickstep/src/com/android/quickstep/TaskHolder.java
index 5755df4f4..49b6aaa99 100644
--- a/go/quickstep/src/com/android/quickstep/TaskHolder.java
+++ b/go/quickstep/src/com/android/quickstep/TaskHolder.java
@@ -15,8 +15,6 @@
*/
package com.android.quickstep;
-import android.graphics.Bitmap;
-
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
@@ -58,12 +56,11 @@ public final class TaskHolder extends ViewHolder {
*/
public void bindTask(@NonNull Task task, boolean willAnimate) {
mTask = task;
- Bitmap thumbnail = (task.thumbnail != null) ? task.thumbnail.thumbnail : null;
if (willAnimate) {
- mTaskItemView.startContentAnimation(task.icon, thumbnail, task.titleDescription);
+ mTaskItemView.startContentAnimation(task.icon, task.thumbnail, task.titleDescription);
} else {
mTaskItemView.setIcon(task.icon);
- mTaskItemView.setThumbnail(thumbnail);
+ mTaskItemView.setThumbnail(task.thumbnail);
mTaskItemView.setLabel(task.titleDescription);
}
}
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index b7ed5b59f..b8c482dd9 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -125,7 +125,7 @@ public final class IconRecentsView extends FrameLayout {
Task task = optTask.get();
// Update thumbnail on the task.
task.thumbnail = thumbnailData;
- taskView.setThumbnail(thumbnailData.thumbnail);
+ taskView.setThumbnail(thumbnailData);
return task;
}
}
diff --git a/go/quickstep/src/com/android/quickstep/views/TaskItemView.java b/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
index 7d9916e5b..0b5ed569c 100644
--- a/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
+++ b/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
@@ -18,9 +18,8 @@ package com.android.quickstep.views;
import static com.android.quickstep.views.TaskLayoutUtils.getTaskHeight;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.FloatProperty;
@@ -33,6 +32,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.android.launcher3.R;
+import com.android.quickstep.ThumbnailDrawable;
+import com.android.systemui.shared.recents.model.ThumbnailData;
/**
* View representing an individual task item with the icon + thumbnail adjacent to the task label.
@@ -132,10 +133,10 @@ public final class TaskItemView extends LinearLayout {
/**
* Set the task thumbnail for the task. Sets to a default thumbnail if null.
*
- * @param thumbnail task thumbnail for the task
+ * @param thumbnailData task thumbnail data for the task
*/
- public void setThumbnail(@Nullable Bitmap thumbnail) {
- mThumbnailDrawable.setCurrentDrawable(getSafeThumbnail(thumbnail));
+ public void setThumbnail(@Nullable ThumbnailData thumbnailData) {
+ mThumbnailDrawable.setCurrentDrawable(getSafeThumbnail(thumbnailData));
}
public View getThumbnailView() {
@@ -151,8 +152,8 @@ public final class TaskItemView extends LinearLayout {
* @param endThumbnail the thumbnail to animate to
* @param endLabel the label to animate to
*/
- public void startContentAnimation(@Nullable Drawable endIcon, @Nullable Bitmap endThumbnail,
- @Nullable String endLabel) {
+ public void startContentAnimation(@Nullable Drawable endIcon,
+ @Nullable ThumbnailData endThumbnail, @Nullable String endLabel) {
mIconDrawable.startNewTransition(getSafeIcon(endIcon));
mThumbnailDrawable.startNewTransition(getSafeThumbnail(endThumbnail));
// TODO: Animation for label
@@ -171,12 +172,27 @@ public final class TaskItemView extends LinearLayout {
return (icon != null) ? icon : mDefaultIcon;
}
- private @NonNull Drawable getSafeThumbnail(@Nullable Bitmap thumbnail) {
- return (thumbnail != null) ? new BitmapDrawable(getResources(), thumbnail)
- : mDefaultThumbnail;
+ private @NonNull Drawable getSafeThumbnail(@Nullable ThumbnailData thumbnailData) {
+ if (thumbnailData == null || thumbnailData.thumbnail == null) {
+ return mDefaultThumbnail;
+ }
+ int orientation = getResources().getConfiguration().orientation;
+ return new ThumbnailDrawable(thumbnailData, orientation /* requestedOrientation */);
}
private @NonNull String getSafeLabel(@Nullable String label) {
return (label != null) ? label : DEFAULT_LABEL;
}
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ int layerCount = mThumbnailDrawable.getNumberOfLayers();
+ for (int i = 0; i < layerCount; i++) {
+ Drawable drawable = mThumbnailDrawable.getDrawable(i);
+ if (drawable instanceof ThumbnailDrawable) {
+ ((ThumbnailDrawable) drawable).setRequestedOrientation(newConfig.orientation);
+ }
+ }
+ }
}