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

Commit c4c800ff authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Change layout size to be dependent on device size" into ub-launcher3-master

parents 260eaa05 c06522c8
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -33,10 +33,9 @@
            android:scrollbars="none"/>
        <Button
            android:id="@+id/clear_all_button"
            android:layout_width="@dimen/clear_all_button_width"
            android:layout_height="@dimen/clear_all_button_height"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginVertical="@dimen/task_item_half_vert_margin"
            android:background="@drawable/clear_all_button"
            android:gravity="center"
            android:text="@string/recents_clear_all"
+7 −8
Original line number Diff line number Diff line
@@ -21,20 +21,19 @@
    android:orientation="horizontal">
    <FrameLayout
        android:id="@+id/task_icon_and_thumbnail"
        android:layout_width="@dimen/task_thumbnail_and_icon_view_size"
        android:layout_height="@dimen/task_thumbnail_and_icon_view_size"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_vertical"
        android:layout_marginHorizontal="8dp"
        android:layout_marginVertical="@dimen/task_item_half_vert_margin">
        android:layout_marginHorizontal="8dp">
        <ImageView
            android:id="@+id/task_thumbnail"
            android:layout_width="@dimen/task_thumbnail_width"
            android:layout_height="@dimen/task_thumbnail_height"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="top|start"/>
        <ImageView
            android:id="@+id/task_icon"
            android:layout_width="@dimen/task_icon_size"
            android:layout_height="@dimen/task_icon_size"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"/>
    </FrameLayout>
    <TextView
+0 −26
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     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.
-->
<resources>
    <dimen name="task_item_half_vert_margin">8dp</dimen>
    <dimen name="task_thumbnail_and_icon_view_size">60dp</dimen>
    <dimen name="task_thumbnail_height">60dp</dimen>
    <dimen name="task_thumbnail_width">36dp</dimen>
    <dimen name="task_icon_size">36dp</dimen>

    <dimen name="clear_all_button_width">106dp</dimen>
    <dimen name="clear_all_button_height">36dp</dimen>
</resources>
 No newline at end of file
+15 −2
Original line number Diff line number Diff line
@@ -15,12 +15,18 @@
 */
package com.android.quickstep;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

import static com.android.quickstep.views.TaskLayoutUtils.getTaskHeight;
import static com.android.quickstep.views.TaskLayoutUtils.getTaskTopMargin;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.Adapter;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.quickstep.views.TaskItemView;
import com.android.systemui.shared.recents.model.Task;
@@ -35,15 +41,17 @@ import java.util.Objects;
public final class TaskAdapter extends Adapter<TaskHolder> {

    public static final int CHANGE_EVENT_TYPE_EMPTY_TO_CONTENT = 0;
    public static final int MAX_TASKS_TO_DISPLAY = 6;

    private static final int MAX_TASKS_TO_DISPLAY = 6;
    private static final String TAG = "TaskAdapter";
    private final TaskListLoader mLoader;
    private final DeviceProfile mDeviceProfile;
    private TaskActionController mTaskActionController;
    private boolean mIsShowingLoadingUi;

    public TaskAdapter(@NonNull TaskListLoader loader) {
    public TaskAdapter(@NonNull TaskListLoader loader, DeviceProfile dp) {
        mLoader = loader;
        mDeviceProfile = dp;
    }

    public void setActionController(TaskActionController taskActionController) {
@@ -66,6 +74,11 @@ public final class TaskAdapter extends Adapter<TaskHolder> {
    public TaskHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        TaskItemView itemView = (TaskItemView) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.task_item_view, parent, false);
        ViewGroup.MarginLayoutParams itemViewParams =
                (ViewGroup.MarginLayoutParams) itemView.getLayoutParams();
        itemViewParams.width = MATCH_PARENT;
        itemViewParams.height = getTaskHeight(mDeviceProfile);
        itemViewParams.topMargin = getTaskTopMargin(mDeviceProfile);
        TaskHolder holder = new TaskHolder(itemView);
        itemView.setOnClickListener(view -> mTaskActionController.launchTask(holder));
        return holder;
+19 −1
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ package com.android.quickstep.views;
import static androidx.recyclerview.widget.LinearLayoutManager.VERTICAL;

import static com.android.quickstep.TaskAdapter.CHANGE_EVENT_TYPE_EMPTY_TO_CONTENT;
import static com.android.quickstep.views.TaskLayoutUtils.getClearAllButtonHeight;
import static com.android.quickstep.views.TaskLayoutUtils.getClearAllButtonTopBottomMargin;
import static com.android.quickstep.views.TaskLayoutUtils.getClearAllButtonWidth;
import static com.android.quickstep.views.TaskLayoutUtils.getTaskListHeight;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -31,6 +35,7 @@ import android.util.AttributeSet;
import android.util.FloatProperty;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;

@@ -43,6 +48,8 @@ import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListener;

import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.quickstep.ContentFillItemAnimator;
import com.android.quickstep.RecentsToActivityHelper;
@@ -96,6 +103,7 @@ public final class IconRecentsView extends FrameLayout {
    private final DefaultItemAnimator mDefaultItemAnimator = new DefaultItemAnimator();
    private final ContentFillItemAnimator mLoadingContentItemAnimator =
            new ContentFillItemAnimator();
    private final DeviceProfile mDeviceProfile;

    private RecentsToActivityHelper mActivityHelper;
    private RecyclerView mTaskRecyclerView;
@@ -109,9 +117,11 @@ public final class IconRecentsView extends FrameLayout {

    public IconRecentsView(Context context, AttributeSet attrs) {
        super(context, attrs);
        BaseActivity activity = BaseActivity.fromContext(context);
        mContext = context;
        mDeviceProfile = activity.getDeviceProfile();
        mTaskLoader = new TaskListLoader(mContext);
        mTaskAdapter = new TaskAdapter(mTaskLoader);
        mTaskAdapter = new TaskAdapter(mTaskLoader, mDeviceProfile);
        mTaskActionController = new TaskActionController(mTaskLoader, mTaskAdapter);
        mTaskAdapter.setActionController(mTaskActionController);
    }
@@ -121,6 +131,8 @@ public final class IconRecentsView extends FrameLayout {
        super.onFinishInflate();
        if (mTaskRecyclerView == null) {
            mTaskRecyclerView = findViewById(R.id.recent_task_recycler_view);
            ViewGroup.LayoutParams recyclerViewParams = mTaskRecyclerView.getLayoutParams();
            recyclerViewParams.height = getTaskListHeight(mDeviceProfile);
            mTaskRecyclerView.setAdapter(mTaskAdapter);
            mTaskRecyclerView.setLayoutManager(
                    new LinearLayoutManager(mContext, VERTICAL, true /* reverseLayout */));
@@ -159,6 +171,12 @@ public final class IconRecentsView extends FrameLayout {
                }
            });
            mClearAllView = findViewById(R.id.clear_all_button);
            MarginLayoutParams clearAllParams =
                    (MarginLayoutParams) mClearAllView.getLayoutParams();
            clearAllParams.height = getClearAllButtonHeight(mDeviceProfile);
            clearAllParams.width = getClearAllButtonWidth(mDeviceProfile);
            clearAllParams.topMargin = getClearAllButtonTopBottomMargin(mDeviceProfile);
            clearAllParams.bottomMargin = getClearAllButtonTopBottomMargin(mDeviceProfile);
            mClearAllView.setOnClickListener(v -> animateClearAllTasks());
        }
    }
Loading