1f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal/*
2f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * Copyright (C) 2018 The Android Open Source Project
3f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal *
4f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * Licensed under the Apache License, Version 2.0 (the "License");
5f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * you may not use this file except in compliance with the License.
6f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * You may obtain a copy of the License at
7f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal *
8f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal *      http://www.apache.org/licenses/LICENSE-2.0
9f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal *
10f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * Unless required by applicable law or agreed to in writing, software
11f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * distributed under the License is distributed on an "AS IS" BASIS,
12f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * See the License for the specific language governing permissions and
14f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal * limitations under the License.
15f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal */
16ab83773e211daf43b6b3ab327be2e94bf61663b3Sunny Goyalpackage com.android.quickstep.fallback;
17f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal
18f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyalimport android.content.Context;
1900c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyalimport android.graphics.Canvas;
20f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyalimport android.graphics.Rect;
21f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyalimport android.util.AttributeSet;
2200c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyalimport android.view.View;
23f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal
24f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyalimport com.android.launcher3.DeviceProfile;
25ab83773e211daf43b6b3ab327be2e94bf61663b3Sunny Goyalimport com.android.quickstep.RecentsActivity;
26d792a7723430cfc84d60af7d885bd51d2159df32Sunny Goyalimport com.android.quickstep.util.LayoutUtils;
27f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyalimport com.android.quickstep.views.RecentsView;
28f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal
29d792a7723430cfc84d60af7d885bd51d2159df32Sunny Goyalpublic class FallbackRecentsView extends RecentsView<RecentsActivity> {
30f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal
31f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    public FallbackRecentsView(Context context, AttributeSet attrs) {
32f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal        this(context, attrs, 0);
33f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    }
34f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal
35f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    public FallbackRecentsView(Context context, AttributeSet attrs, int defStyleAttr) {
36f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal        super(context, attrs, defStyleAttr);
37f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal        setOverviewStateEnabled(true);
389829060491919e7651b9437181e9e8e1ffd8633fSunny Goyal        getQuickScrubController().onFinishedTransitionToQuickScrub();
39f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    }
40f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal
41f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    @Override
42f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    protected void onAllTasksRemoved() {
43681bab045a346c6e1ec3c448b5f98a82e6ce7359Sunny Goyal        mActivity.startHome();
44f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    }
45f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal
46f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    @Override
4700c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal    public void onViewAdded(View child) {
4800c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal        super.onViewAdded(child);
4900c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal        updateEmptyMessage();
5000c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal    }
5100c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal
5200c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal    @Override
5300c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal    public void onViewRemoved(View child) {
5400c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal        super.onViewRemoved(child);
5500c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal        updateEmptyMessage();
5600c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal    }
5700c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal
5800c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal    @Override
59d792a7723430cfc84d60af7d885bd51d2159df32Sunny Goyal    public void draw(Canvas canvas) {
60d792a7723430cfc84d60af7d885bd51d2159df32Sunny Goyal        maybeDrawEmptyMessage(canvas);
61d792a7723430cfc84d60af7d885bd51d2159df32Sunny Goyal        super.draw(canvas);
62f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal    }
639d69c8da9a4f933cc700ef1672b4e60d34a2fb10Sunny Goyal
64d792a7723430cfc84d60af7d885bd51d2159df32Sunny Goyal    @Override
65d792a7723430cfc84d60af7d885bd51d2159df32Sunny Goyal    protected void getTaskSize(DeviceProfile dp, Rect outRect) {
6676257f2535c43ff6ee67bf8ef20feab3fb6255d4Sunny Goyal        LayoutUtils.calculateFallbackTaskSize(getContext(), dp, outRect);
679d69c8da9a4f933cc700ef1672b4e60d34a2fb10Sunny Goyal    }
6800c9c9a6fc551fef89658a11abe544248247f3b6Sunny Goyal
69f3d7328518201927e364c7a7529e311a4bb00607Sunny Goyal    @Override
70f3d7328518201927e364c7a7529e311a4bb00607Sunny Goyal    public boolean shouldUseMultiWindowTaskSizeStrategy() {
71f3d7328518201927e364c7a7529e311a4bb00607Sunny Goyal        // Just use the activity task size for multi-window as well.
72f3d7328518201927e364c7a7529e311a4bb00607Sunny Goyal        return false;
73f3d7328518201927e364c7a7529e311a4bb00607Sunny Goyal    }
74f633ef5f4310b6f79087797a2dc215812f841b70Sunny Goyal}
75