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

Commit 82c8c5e9 authored by Winson Chung's avatar Winson Chung
Browse files

DO NOT MERGE Using a fixed sized ImageView to prevent unnecessary layouts.

- Preparing for task view clipping using the view outline

Change-Id: I4aae4189a759a48057f1e3729cc2a9e6d553c11e
parent 0b23e20b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
        android:layout_height="@dimen/recents_task_bar_height"
        android:layout_gravity="top|center_horizontal"
        android:background="@color/recents_task_bar_default_background_color">
        <ImageView
        <com.android.systemui.recents.views.FixedSizeImageView
            android:id="@+id/application_icon"
            android:layout_width="@dimen/recents_task_view_application_icon_size"
            android:layout_height="@dimen/recents_task_view_application_icon_size"
@@ -51,7 +51,7 @@
            android:maxLines="2"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal" />
        <ImageView
        <com.android.systemui.recents.views.FixedSizeImageView
            android:id="@+id/dismiss_task"
            android:layout_width="48dp"
            android:layout_height="48dp"
+1 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import com.android.systemui.recents.misc.SystemServicesProxy;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * The package monitor listens for changes from PackageManager to update the contents of the Recents
@@ -33,7 +32,7 @@ import java.util.Set;
 */
public class RecentsPackageMonitor extends PackageMonitor {
    public interface PackageCallbacks {
        public void onComponentRemoved(Set<ComponentName> cns);
        public void onComponentRemoved(HashSet<ComponentName> cns);
    }

    PackageCallbacks mCb;
+1 −1
Original line number Diff line number Diff line
@@ -204,8 +204,8 @@ public class TaskStack {
                removeGroup(group);
            }
            // Update the lock-to-app state
            Task newFrontMostTask = getFrontMostTask();
            t.canLockToTask = false;
            Task newFrontMostTask = getFrontMostTask();
            if (newFrontMostTask != null) {
                newFrontMostTask.canLockToTask = true;
            }
+82 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.systemui.recents.views;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * This is an optimized ImageView that does not trigger a requestLayout() or invalidate() when
 * setting the image to Null.
 */
public class FixedSizeImageView extends ImageView {

    int mFixedWidth;
    int mFixedHeight;
    boolean mAllowRelayout = true;
    boolean mAllowInvalidate = true;

    public FixedSizeImageView(Context context) {
        this(context, null);
    }

    public FixedSizeImageView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FixedSizeImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public FixedSizeImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        mFixedWidth = getMeasuredWidth();
        mFixedHeight = getMeasuredHeight();
    }

    @Override
    public void requestLayout() {
        if (mAllowRelayout) {
            super.requestLayout();
        }
    }

    @Override
    public void invalidate() {
        if (mAllowInvalidate) {
            super.invalidate();
        }
    }

    @Override
    public void setImageDrawable(Drawable drawable) {
        if (drawable == null || (mFixedWidth > 0 && mFixedHeight > 0)) {
            mAllowRelayout = false;
            mAllowInvalidate = false;
        }
        super.setImageDrawable(drawable);
        mAllowRelayout = true;
        mAllowInvalidate = true;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;

import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;

/**
 * This view is the the top level layout that contains TaskStacks (which are laid out according
@@ -551,7 +551,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
    /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/

    @Override
    public void onComponentRemoved(Set<ComponentName> cns) {
    public void onComponentRemoved(HashSet<ComponentName> cns) {
        // Propagate this event down to each task stack view
        int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
Loading