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

Commit c9567c07 authored by Winson Chung's avatar Winson Chung
Browse files

Ensuring that null thumbnails have an opaque background.

- Preventing multiple object allocations when updating the stack/clip state.
- Removing double animation of nav bar when launching task

Change-Id: Id12009717135db67bc0ce0e05940dd1c8d6fb5b3
parent 969f5865
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class Constants {
            // For debugging, this defines the number of mock recents packages to create
            public static final int SystemServicesProxyMockPackageCount = 3;
            // For debugging, this defines the number of mock recents tasks to create
            public static final int SystemServicesProxyMockTaskCount = 75;
            public static final int SystemServicesProxyMockTaskCount = 100;
        }
    }

+1 −6
Original line number Diff line number Diff line
@@ -605,14 +605,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    }

    @Override
    public void onTaskLaunching(boolean isTaskInStackBounds) {
    public void onTaskLaunching() {
        mTaskLaunched = true;

        // Fade out the scrim
        if (!isTaskInStackBounds && mConfig.hasNavBarScrim()) {
            onExitAnimationTriggered();
        }

        // Mark recents as no longer visible
        AlternateRecentsComponent.notifyVisibilityChanged(false);
    }
+15 −6
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ class TaskResourceLoader implements Runnable {
    TaskResourceLoadQueue mLoadQueue;
    DrawableLruCache mApplicationIconCache;
    BitmapLruCache mThumbnailCache;
    Bitmap mDefaultThumbnail;

    boolean mCancelled;
    boolean mWaitingOnLoadQueue;
@@ -125,10 +126,12 @@ class TaskResourceLoader implements Runnable {
    /** Constructor, creates a new loading thread that loads task resources in the background */
    public TaskResourceLoader(TaskResourceLoadQueue loadQueue,
                              DrawableLruCache applicationIconCache,
                              BitmapLruCache thumbnailCache) {
                              BitmapLruCache thumbnailCache,
                              Bitmap defaultThumbnail) {
        mLoadQueue = loadQueue;
        mApplicationIconCache = applicationIconCache;
        mThumbnailCache = thumbnailCache;
        mDefaultThumbnail = defaultThumbnail;
        mMainThreadHandler = new Handler();
        mLoadThread = new HandlerThread("Recents-TaskResourceLoader");
        mLoadThread.setPriority(Thread.NORM_PRIORITY - 1);
@@ -238,6 +241,7 @@ class TaskResourceLoader implements Runnable {
                                loadThumbnail = thumbnail;
                                mThumbnailCache.put(t.key, thumbnail);
                            } else {
                                loadThumbnail = mDefaultThumbnail;
                                Console.logError(mContext,
                                        "Failed to load task top thumbnail for: " +
                                                t.key.baseIntent.getComponent().getPackageName());
@@ -330,6 +334,7 @@ public class RecentsTaskLoader {

    BitmapDrawable mDefaultApplicationIcon;
    Bitmap mDefaultThumbnail;
    Bitmap mLoadingThumbnail;

    /** Private Constructor */
    private RecentsTaskLoader(Context context) {
@@ -356,18 +361,22 @@ public class RecentsTaskLoader {
        mLoadQueue = new TaskResourceLoadQueue();
        mApplicationIconCache = new DrawableLruCache(iconCacheSize);
        mThumbnailCache = new BitmapLruCache(thumbnailCacheSize);
        mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache);
        mLoader = new TaskResourceLoader(mLoadQueue, mApplicationIconCache, mThumbnailCache,
                mDefaultThumbnail);

        // Create the default assets
        Bitmap icon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
        icon.eraseColor(0x00000000);
        mDefaultThumbnail = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
        mDefaultThumbnail.eraseColor(0x00000000);
        mDefaultThumbnail.eraseColor(0xFFffffff);
        mLoadingThumbnail = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
        mLoadingThumbnail.eraseColor(0x00000000);
        mDefaultApplicationIcon = new BitmapDrawable(context.getResources(), icon);
        if (Console.Enabled) {
            Console.log(Constants.Log.App.TaskDataLoader,
                    "[RecentsTaskLoader|defaultBitmaps]",
                    "icon: " + mDefaultApplicationIcon + " thumbnail: " + mDefaultThumbnail, Console.AnsiRed);
                    "icon: " + mDefaultApplicationIcon +
                    " default thumbnail: " + mDefaultThumbnail, Console.AnsiRed);
        }
    }

@@ -394,7 +403,7 @@ public class RecentsTaskLoader {

        SystemServicesProxy ssp = mSystemServicesProxy;
        List<ActivityManager.RecentTaskInfo> tasks =
                ssp.getRecentTasks(100, UserHandle.CURRENT.getIdentifier());
                ssp.getRecentTasks(50, UserHandle.CURRENT.getIdentifier());
        Collections.reverse(tasks);
        if (Console.Enabled) {
            Console.log(Constants.Log.App.TimeSystemCalls,
@@ -544,7 +553,7 @@ public class RecentsTaskLoader {
            requiresLoad = true;
        }
        if (thumbnail == null) {
            thumbnail = mDefaultThumbnail;
            thumbnail = mLoadingThumbnail;
            requiresLoad = true;
        }
        if (requiresLoad) {
+5 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
@@ -49,8 +50,8 @@ public class FullScreenTransitionView extends FrameLayout {
    FullScreenTransitionViewCallbacks mCb;

    ImageView mScreenshotView;

    Rect mClipRect = new Rect();
    Paint mLayerPaint = new Paint();

    boolean mIsAnimating;
    AnimatorSet mEnterAnimation;
@@ -159,7 +160,7 @@ public class FullScreenTransitionView extends FrameLayout {
        int clipBottom = mConfig.systemInsets.top + (int) (ctx.taskRect.height() / scale);

        // Enable the HW Layers on the screenshot view
        mScreenshotView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        mScreenshotView.setLayerType(View.LAYER_TYPE_HARDWARE, mLayerPaint);

        // Compose the animation
        mEnterAnimation = new AnimatorSet();
@@ -173,7 +174,7 @@ public class FullScreenTransitionView extends FrameLayout {
                // Mark that we are no longer animating
                mIsAnimating = false;
                // Disable the HW Layers on this view
                setLayerType(View.LAYER_TYPE_NONE, null);
                setLayerType(View.LAYER_TYPE_NONE, mLayerPaint);

                if (Console.Enabled) {
                    Console.logTraceTime(Constants.Log.App.TimeRecentsScreenshotTransition,
@@ -217,7 +218,7 @@ public class FullScreenTransitionView extends FrameLayout {
                    // Mark that we are no longer animating
                    mIsAnimating = false;
                    // Disable the HW Layers on the screenshot view
                    mScreenshotView.setLayerType(View.LAYER_TYPE_NONE, null);
                    mScreenshotView.setLayerType(View.LAYER_TYPE_NONE, mLayerPaint);
                }
            });
            mEnterAnimation.setDuration(475);
+2 −6
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV

    /** The RecentsView callbacks */
    public interface RecentsViewCallbacks {
        public void onTaskLaunching(boolean isTaskInStackBounds);
        public void onTaskLaunching();
        public void onExitAnimationTriggered();
    }

@@ -389,11 +389,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                               final TaskStack stack, final Task task) {
        // Notify any callbacks of the launching of a new task
        if (mCb != null) {
            boolean isTaskInStackBounds = false;
            if (stackView != null && tv != null) {
                isTaskInStackBounds = stackView.isTaskInStackBounds(tv);
            }
            mCb.onTaskLaunching(isTaskInStackBounds);
            mCb.onTaskLaunching();
        }

        final Runnable launchRunnable = new Runnable() {
Loading