summaryrefslogtreecommitdiffstats
path: root/go
diff options
context:
space:
mode:
authorKevin <kevhan@google.com>2019-04-29 10:56:24 -0700
committerKevin <kevhan@google.com>2019-04-29 14:48:48 -0700
commitad8ca82e61206ee3c0e064e39f57272aebf3cf66 (patch)
tree77f8d19f81d3a9f5803c30d762a7f3289210a685 /go
parenteb815415da35c68ba05cc57c844b46c69be99b02 (diff)
downloadandroid_packages_apps_Trebuchet-ad8ca82e61206ee3c0e064e39f57272aebf3cf66.tar.gz
android_packages_apps_Trebuchet-ad8ca82e61206ee3c0e064e39f57272aebf3cf66.tar.bz2
android_packages_apps_Trebuchet-ad8ca82e61206ee3c0e064e39f57272aebf3cf66.zip
Layout aligned to dp grid for portrait (2/3)
Add vertical margins to all recycler items. In the future, we will change these dynamically to ensure a task item is semi-visible on screen Bug: 131610834 Test: Builds Change-Id: I0b21c8ea7249e7fac640705e8128e309b954815b
Diffstat (limited to 'go')
-rw-r--r--go/quickstep/res/values/dimens.xml2
-rw-r--r--go/quickstep/src/com/android/quickstep/views/IconRecentsView.java28
2 files changed, 29 insertions, 1 deletions
diff --git a/go/quickstep/res/values/dimens.xml b/go/quickstep/res/values/dimens.xml
index db3cc213a..0be5ee625 100644
--- a/go/quickstep/res/values/dimens.xml
+++ b/go/quickstep/res/values/dimens.xml
@@ -16,10 +16,12 @@
-->
<resources>
<dimen name="task_item_height">60dp</dimen>
+ <dimen name="task_item_top_margin">16dp</dimen>
<dimen name="task_thumbnail_icon_horiz_margin">16dp</dimen>
<dimen name="task_thumbnail_corner_radius">3dp</dimen>
<dimen name="clear_all_item_view_height">36dp</dimen>
+ <dimen name="clear_all_item_view_top_margin">20dp</dimen>
<dimen name="clear_all_button_width">106dp</dimen>
</resources> \ 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
index e4795ce02..f0795150c 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -20,6 +20,8 @@ import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static androidx.recyclerview.widget.LinearLayoutManager.VERTICAL;
import static com.android.quickstep.TaskAdapter.CHANGE_EVENT_TYPE_EMPTY_TO_CONTENT;
+import static com.android.quickstep.TaskAdapter.ITEM_TYPE_CLEAR_ALL;
+import static com.android.quickstep.TaskAdapter.ITEM_TYPE_TASK;
import static com.android.quickstep.TaskAdapter.TASKS_START_POSITION;
import android.animation.Animator;
@@ -29,6 +31,7 @@ import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.content.Context;
+import android.graphics.Rect;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.FloatProperty;
@@ -44,6 +47,7 @@ import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
+import androidx.recyclerview.widget.RecyclerView.ItemDecoration;
import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListener;
import com.android.launcher3.BaseActivity;
@@ -174,7 +178,29 @@ public final class IconRecentsView extends FrameLayout {
mTaskRecyclerView.setItemAnimator(mDefaultItemAnimator);
mLoadingContentItemAnimator.setOnAnimationFinishedRunnable(
() -> mTaskRecyclerView.setItemAnimator(new DefaultItemAnimator()));
- // TODO: Add item decorator for vertical item margins
+ ItemDecoration marginDecorator = new ItemDecoration() {
+ @Override
+ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view,
+ @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
+ // TODO: Determine if current margins cause off screen item to be fully off
+ // screen and if so, modify them so that it is partially off screen.
+ int itemType = parent.getChildViewHolder(view).getItemViewType();
+ switch (itemType) {
+ case ITEM_TYPE_CLEAR_ALL:
+ outRect.top = (int) getResources().getDimension(
+ R.dimen.clear_all_item_view_top_margin);
+ // TODO: In landscape, add bottom margin as well since we won't have
+ // nav bar to buffer things nicely.
+ break;
+ case ITEM_TYPE_TASK:
+ outRect.top = (int) getResources().getDimension(
+ R.dimen.task_item_top_margin);
+ break;
+ default:
+ }
+ }
+ };
+ mTaskRecyclerView.addItemDecoration(marginDecorator);
mEmptyView = findViewById(R.id.recent_task_empty_view);
mContentView = mTaskRecyclerView;