summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Cling.java
blob: a6139ccbc58179f8780fe38bcb08dfc0fdbf7426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
/*
 * Copyright (C) 2011 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.launcher3;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.FocusFinder;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.TextView;

public class Cling extends FrameLayout implements Insettable, View.OnClickListener,
        View.OnLongClickListener, View.OnTouchListener {

    private static String FIRST_RUN_PORTRAIT = "first_run_portrait";
    private static String FIRST_RUN_LANDSCAPE = "first_run_landscape";

    private static String WORKSPACE_PORTRAIT = "workspace_portrait";
    private static String WORKSPACE_LANDSCAPE = "workspace_landscape";
    private static String WORKSPACE_LARGE = "workspace_large";
    private static String WORKSPACE_CUSTOM = "workspace_custom";

    private static String MIGRATION_PORTRAIT = "migration_portrait";
    private static String MIGRATION_LANDSCAPE = "migration_landscape";

    private static String MIGRATION_WORKSPACE_PORTRAIT = "migration_workspace_portrait";
    private static String MIGRATION_WORKSPACE_LARGE_PORTRAIT = "migration_workspace_large_portrait";
    private static String MIGRATION_WORKSPACE_LANDSCAPE = "migration_workspace_landscape";

    private static String FOLDER_PORTRAIT = "folder_portrait";
    private static String FOLDER_LANDSCAPE = "folder_landscape";
    private static String FOLDER_LARGE = "folder_large";

    private static float FIRST_RUN_CIRCLE_BUFFER_DPS = 60;
    private static float FIRST_RUN_MAX_CIRCLE_RADIUS_DPS = 180;
    private static float WORKSPACE_INNER_CIRCLE_RADIUS_DPS = 50;
    private static float WORKSPACE_OUTER_CIRCLE_RADIUS_DPS = 60;
    private static float WORKSPACE_CIRCLE_Y_OFFSET_DPS = 30;
    private static float MIGRATION_WORKSPACE_INNER_CIRCLE_RADIUS_DPS = 42;
    private static float MIGRATION_WORKSPACE_OUTER_CIRCLE_RADIUS_DPS = 46;

    private Launcher mLauncher;
    private boolean mIsInitialized;
    private String mDrawIdentifier;
    private Drawable mBackground;

    private int[] mTouchDownPt = new int[2];

    private Drawable mFocusedHotseatApp;
    private ComponentName mFocusedHotseatAppComponent;
    private Rect mFocusedHotseatAppBounds;

    private Paint mErasePaint;
    private Paint mBorderPaint;
    private Paint mBubblePaint;
    private Paint mDotPaint;

    private View mScrimView;
    private int mBackgroundColor;

    private final Rect mInsets = new Rect();

    public Cling(Context context) {
        this(context, null, 0);
    }

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

    public Cling(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Cling, defStyle, 0);
        mDrawIdentifier = a.getString(R.styleable.Cling_drawIdentifier);
        a.recycle();

        setClickable(true);

    }

    void init(Launcher l, View scrim) {
        if (!mIsInitialized) {
            mLauncher = l;
            mScrimView = scrim;
            mBackgroundColor = 0xcc000000;
            setOnLongClickListener(this);
            setOnClickListener(this);
            setOnTouchListener(this);

            mErasePaint = new Paint();
            mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
            mErasePaint.setColor(0xFFFFFF);
            mErasePaint.setAlpha(0);
            mErasePaint.setAntiAlias(true);

            mBorderPaint = new Paint();
            mBorderPaint.setColor(0xFFFFFFFF);
            mBorderPaint.setAntiAlias(true);

            int circleColor = getResources().getColor(
                    R.color.first_run_cling_circle_background_color);
            mBubblePaint = new Paint();
            mBubblePaint.setColor(circleColor);
            mBubblePaint.setAntiAlias(true);

            mDotPaint = new Paint();
            mDotPaint.setColor(0x72BBED);
            mDotPaint.setAntiAlias(true);

            mIsInitialized = true;
        }
    }

    void setFocusedHotseatApp(int drawableId, int appRank, ComponentName cn, String title,
                              String description) {
        // Get the app to draw
        Resources r = getResources();
        int appIconId = drawableId;
        Hotseat hotseat = mLauncher.getHotseat();
        // Skip the focused app in the large layouts
        if (!mDrawIdentifier.equals(WORKSPACE_LARGE) &&
                hotseat != null && appIconId > -1 && appRank > -1 && !title.isEmpty() &&
                !description.isEmpty()) {
            // Set the app bounds
            int x = hotseat.getCellXFromOrder(appRank);
            int y = hotseat.getCellYFromOrder(appRank);
            Rect pos = hotseat.getCellCoordinates(x, y);
            LauncherAppState app = LauncherAppState.getInstance();
            DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
            mFocusedHotseatApp = getResources().getDrawable(appIconId);
            mFocusedHotseatAppComponent = cn;
            mFocusedHotseatAppBounds = new Rect(pos.left, pos.top,
                    pos.left + Utilities.sIconTextureWidth,
                    pos.top + Utilities.sIconTextureHeight);
            Utilities.scaleRectAboutCenter(mFocusedHotseatAppBounds,
                    ((float) grid.hotseatIconSizePx / grid.iconSizePx));

            // Set the title
            TextView v = (TextView) findViewById(R.id.focused_hotseat_app_title);
            if (v != null) {
                v.setText(title);
            }

            // Set the description
            v = (TextView) findViewById(R.id.focused_hotseat_app_description);
            if (v != null) {
                v.setText(description);
            }

            // Show the bubble
            View bubble = findViewById(R.id.focused_hotseat_app_bubble);
            bubble.setVisibility(View.VISIBLE);
        }
    }

    void setOpenFolderRect(Rect r) {
        if (mDrawIdentifier.equals(FOLDER_LANDSCAPE) ||
            mDrawIdentifier.equals(FOLDER_LARGE)) {
            ViewGroup vg = (ViewGroup) findViewById(R.id.folder_bubble);
            ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) vg.getLayoutParams();
            lp.topMargin = r.top - mInsets.bottom;
            lp.leftMargin = r.right;
            vg.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
            vg.requestLayout();
        }
    }

    void updateMigrationWorkspaceBubblePosition() {
        DisplayMetrics metrics = new DisplayMetrics();
        mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        // Get the page indicator bounds
        LauncherAppState app = LauncherAppState.getInstance();
        DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
        Rect pageIndicatorBounds = grid.getWorkspacePageIndicatorBounds(mInsets);

        if (mDrawIdentifier.equals(MIGRATION_WORKSPACE_PORTRAIT)) {
            View bubble = findViewById(R.id.migration_workspace_cling_bubble);
            ViewGroup.MarginLayoutParams lp =
                    (ViewGroup.MarginLayoutParams) bubble.getLayoutParams();
            lp.bottomMargin = grid.heightPx - pageIndicatorBounds.top;
            bubble.requestLayout();
        } else if (mDrawIdentifier.equals(MIGRATION_WORKSPACE_LARGE_PORTRAIT)) {
            View bubble = findViewById(R.id.content);
            ViewGroup.MarginLayoutParams lp =
                    (ViewGroup.MarginLayoutParams) bubble.getLayoutParams();
            lp.bottomMargin = grid.heightPx - pageIndicatorBounds.top;
            bubble.requestLayout();
        } else if (mDrawIdentifier.equals(MIGRATION_WORKSPACE_LANDSCAPE)) {
            View bubble = findViewById(R.id.content);
            ViewGroup.MarginLayoutParams lp =
                    (ViewGroup.MarginLayoutParams) bubble.getLayoutParams();
            if (grid.isLayoutRtl) {
                lp.leftMargin = pageIndicatorBounds.right;
            } else {
                lp.rightMargin = (grid.widthPx - pageIndicatorBounds.left);
            }
            bubble.requestLayout();
        }
    }

    void updateWorkspaceBubblePosition() {
        DisplayMetrics metrics = new DisplayMetrics();
        mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metrics);

        // Get the cut-out bounds
        LauncherAppState app = LauncherAppState.getInstance();
        DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
        Rect cutOutBounds = getWorkspaceCutOutBounds(metrics);

        if (mDrawIdentifier.equals(WORKSPACE_LARGE)) {
            View bubble = findViewById(R.id.workspace_cling_bubble);
            ViewGroup.MarginLayoutParams lp =
                    (ViewGroup.MarginLayoutParams) bubble.getLayoutParams();
            lp.bottomMargin = grid.heightPx - cutOutBounds.top - mInsets.bottom;
            bubble.requestLayout();
        }
    }

    private Rect getWorkspaceCutOutBounds(DisplayMetrics metrics) {
        int halfWidth = metrics.widthPixels / 2;
        int halfHeight = metrics.heightPixels / 2;
        int yOffset = DynamicGrid.pxFromDp(WORKSPACE_CIRCLE_Y_OFFSET_DPS, metrics);
        if (mDrawIdentifier.equals(WORKSPACE_LARGE)) {
            yOffset = 0;
        }
        int radius = DynamicGrid.pxFromDp(WORKSPACE_OUTER_CIRCLE_RADIUS_DPS, metrics);
        return new Rect(halfWidth - radius, halfHeight - yOffset - radius, halfWidth + radius,
                halfHeight - yOffset + radius);
    }

    void show(boolean animate, int duration) {
        setVisibility(View.VISIBLE);
        setLayerType(View.LAYER_TYPE_HARDWARE, null);
        if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
                mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
                mDrawIdentifier.equals(WORKSPACE_LARGE) ||
                mDrawIdentifier.equals(WORKSPACE_CUSTOM) ||
                mDrawIdentifier.equals(MIGRATION_WORKSPACE_PORTRAIT) ||
                mDrawIdentifier.equals(MIGRATION_WORKSPACE_LARGE_PORTRAIT) ||
                mDrawIdentifier.equals(MIGRATION_WORKSPACE_LANDSCAPE)) {
            View content = getContent();
            content.setAlpha(0f);
            content.animate()
                    .alpha(1f)
                    .setDuration(duration)
                    .setListener(null)
                    .start();
            setAlpha(1f);
        } else {
            if (animate) {
                buildLayer();
                setAlpha(0f);
                animate()
                    .alpha(1f)
                    .setInterpolator(new AccelerateInterpolator())
                    .setDuration(duration)
                    .setListener(null)
                    .start();
            } else {
                setAlpha(1f);
            }
        }

        // Show the scrim if necessary
        if (mScrimView != null) {
            mScrimView.setVisibility(View.VISIBLE);
            mScrimView.setAlpha(0f);
            mScrimView.animate()
                    .alpha(1f)
                    .setDuration(duration)
                    .setListener(null)
                    .start();
        }

        setFocusableInTouchMode(true);
        post(new Runnable() {
            public void run() {
                setFocusable(true);
                requestFocus();
            }
        });
    }

    void hide(final int duration, final Runnable postCb) {
        if (mDrawIdentifier.equals(FIRST_RUN_PORTRAIT) ||
                mDrawIdentifier.equals(FIRST_RUN_LANDSCAPE) ||
                mDrawIdentifier.equals(MIGRATION_PORTRAIT) ||
                mDrawIdentifier.equals(MIGRATION_LANDSCAPE)) {
            View content = getContent();
            content.animate()
                .alpha(0f)
                .setDuration(duration)
                .setListener(new AnimatorListenerAdapter() {
                    public void onAnimationEnd(Animator animation) {
                        // We are about to trigger the workspace cling, so don't do anything else
                        setVisibility(View.GONE);
                        postCb.run();
                    };
                })
                .start();
        } else {
            animate()
                .alpha(0f)
                .setDuration(duration)
                .setListener(new AnimatorListenerAdapter() {
                    public void onAnimationEnd(Animator animation) {
                        // We are about to trigger the workspace cling, so don't do anything else
                        setVisibility(View.GONE);
                        postCb.run();
                    };
                })
                .start();
        }

        // Show the scrim if necessary
        if (mScrimView != null) {
            mScrimView.animate()
                .alpha(0f)
                .setDuration(duration)
                .setListener(new AnimatorListenerAdapter() {
                    public void onAnimationEnd(Animator animation) {
                        mScrimView.setVisibility(View.GONE);
                    };
                })
                .start();
        }
    }

    void cleanup() {
        mBackground = null;
        mIsInitialized = false;
    }

    void bringScrimToFront() {
        if (mScrimView != null) {
            mScrimView.bringToFront();
        }
    }

    @Override
    public void setInsets(Rect insets) {
        mInsets.set(insets);
        setPadding(insets.left, insets.top, insets.right, insets.bottom);
    }

    View getContent() {
        return findViewById(R.id.content);
    }

    String getDrawIdentifier() {
        return mDrawIdentifier;
    }

    @Override
    public View focusSearch(int direction) {
        return this.focusSearch(this, direction);
    }

    @Override
    public View focusSearch(View focused, int direction) {
        return FocusFinder.getInstance().findNextFocus(this, focused, direction);
    }

    @Override
    public boolean onHoverEvent(MotionEvent event) {
        return (mDrawIdentifier.equals(WORKSPACE_PORTRAIT)
                || mDrawIdentifier.equals(WORKSPACE_LANDSCAPE)
                || mDrawIdentifier.equals(WORKSPACE_LARGE)
                || mDrawIdentifier.equals(WORKSPACE_CUSTOM));
    }

    @Override
    public boolean onTouchEvent(android.view.MotionEvent event) {
        if (mDrawIdentifier.equals(FOLDER_PORTRAIT) ||
                   mDrawIdentifier.equals(FOLDER_LANDSCAPE) ||
                   mDrawIdentifier.equals(FOLDER_LARGE)) {
            Folder f = mLauncher.getWorkspace().getOpenFolder();
            if (f != null) {
                Rect r = new Rect();
                f.getHitRect(r);
                if (r.contains((int) event.getX(), (int) event.getY())) {
                    return false;
                }
            }
        }
        return super.onTouchEvent(event);
    };

    @Override
    public boolean onTouch(View v, MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            mTouchDownPt[0] = (int) ev.getX();
            mTouchDownPt[1] = (int) ev.getY();
        }
        return false;
    }

    @Override
    public void onClick(View v) {
        if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
                mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
                mDrawIdentifier.equals(WORKSPACE_LARGE)) {
            if (mFocusedHotseatAppBounds != null &&
                mFocusedHotseatAppBounds.contains(mTouchDownPt[0], mTouchDownPt[1])) {
                // Launch the activity that is being highlighted
                Intent intent = new Intent(Intent.ACTION_MAIN);
                intent.setComponent(mFocusedHotseatAppComponent);
                intent.addCategory(Intent.CATEGORY_LAUNCHER);
                mLauncher.startActivity(intent, null);
                mLauncher.getLauncherClings().dismissWorkspaceCling(this);
            }
        }
    }

    @Override
    public boolean onLongClick(View v) {
        if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
                mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
                mDrawIdentifier.equals(WORKSPACE_LARGE)) {
            mLauncher.getLauncherClings().dismissWorkspaceCling(null);
            return true;
        } else if (mDrawIdentifier.equals(MIGRATION_WORKSPACE_PORTRAIT) ||
                mDrawIdentifier.equals(MIGRATION_WORKSPACE_LARGE_PORTRAIT) ||
                mDrawIdentifier.equals(MIGRATION_WORKSPACE_LANDSCAPE)) {
            mLauncher.getLauncherClings().dismissMigrationWorkspaceCling(null);
            return true;
        }
        return false;
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        if (mIsInitialized) {
            canvas.save();

            // Get the page indicator bounds
            LauncherAppState app = LauncherAppState.getInstance();
            DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
            Rect pageIndicatorBounds = grid.getWorkspacePageIndicatorBounds(mInsets);

            // Get the background override if there is one
            if (mBackground == null) {
                if (mDrawIdentifier.equals(WORKSPACE_CUSTOM)) {
                    mBackground = getResources().getDrawable(R.drawable.bg_cling5);
                }
            }
            // Draw the background
            Bitmap eraseBg = null;
            Canvas eraseCanvas = null;
            if (mScrimView != null) {
                // Skip drawing the background
                mScrimView.setBackgroundColor(mBackgroundColor);
            } else if (mBackground != null) {
                mBackground.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
                mBackground.draw(canvas);
            } else if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
                    mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
                    mDrawIdentifier.equals(WORKSPACE_LARGE) ||
                    mDrawIdentifier.equals(MIGRATION_WORKSPACE_PORTRAIT) ||
                    mDrawIdentifier.equals(MIGRATION_WORKSPACE_LARGE_PORTRAIT) ||
                    mDrawIdentifier.equals(MIGRATION_WORKSPACE_LANDSCAPE)) {
                // Initialize the draw buffer (to allow punching through)
                eraseBg = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(),
                        Bitmap.Config.ARGB_8888);
                eraseCanvas = new Canvas(eraseBg);
                eraseCanvas.drawColor(mBackgroundColor);
            } else {
                canvas.drawColor(mBackgroundColor);
            }

            // Draw everything else
            DisplayMetrics metrics = new DisplayMetrics();
            mLauncher.getWindowManager().getDefaultDisplay().getMetrics(metrics);
            float alpha = getAlpha();
            View content = getContent();
            if (content != null) {
                alpha *= content.getAlpha();
            }
            if (mDrawIdentifier.equals(FIRST_RUN_PORTRAIT) ||
                    mDrawIdentifier.equals(FIRST_RUN_LANDSCAPE)) {
                // Draw the circle
                View bubbleContent = findViewById(R.id.bubble_content);
                Rect bubbleRect = new Rect();
                bubbleContent.getGlobalVisibleRect(bubbleRect);
                mBubblePaint.setAlpha((int) (255 * alpha));
                float buffer = DynamicGrid.pxFromDp(FIRST_RUN_CIRCLE_BUFFER_DPS, metrics);
                float maxRadius = DynamicGrid.pxFromDp(FIRST_RUN_MAX_CIRCLE_RADIUS_DPS, metrics);
                float radius = Math.min(maxRadius, (bubbleContent.getMeasuredWidth() + buffer) / 2);
                canvas.drawCircle(metrics.widthPixels / 2,
                        bubbleRect.centerY(), radius,
                        mBubblePaint);
            } else if (mDrawIdentifier.equals(WORKSPACE_PORTRAIT) ||
                    mDrawIdentifier.equals(WORKSPACE_LANDSCAPE) ||
                    mDrawIdentifier.equals(WORKSPACE_LARGE)) {
                Rect cutOutBounds = getWorkspaceCutOutBounds(metrics);
                // Draw the outer circle
                mErasePaint.setAlpha(128);
                eraseCanvas.drawCircle(cutOutBounds.centerX(), cutOutBounds.centerY(),
                        DynamicGrid.pxFromDp(WORKSPACE_OUTER_CIRCLE_RADIUS_DPS, metrics),
                        mErasePaint);
                // Draw the inner circle
                mErasePaint.setAlpha(0);
                eraseCanvas.drawCircle(cutOutBounds.centerX(), cutOutBounds.centerY(),
                        DynamicGrid.pxFromDp(WORKSPACE_INNER_CIRCLE_RADIUS_DPS, metrics),
                        mErasePaint);
                canvas.drawBitmap(eraseBg, 0, 0, null);
                eraseCanvas.setBitmap(null);
                eraseBg = null;

                // Draw the focused hotseat app icon
                if (mFocusedHotseatAppBounds != null && mFocusedHotseatApp != null) {
                    mFocusedHotseatApp.setBounds(mFocusedHotseatAppBounds.left,
                            mFocusedHotseatAppBounds.top, mFocusedHotseatAppBounds.right,
                            mFocusedHotseatAppBounds.bottom);
                    mFocusedHotseatApp.setAlpha((int) (255 * alpha));
                    mFocusedHotseatApp.draw(canvas);
                }
            } else if (mDrawIdentifier.equals(MIGRATION_WORKSPACE_PORTRAIT) ||
                    mDrawIdentifier.equals(MIGRATION_WORKSPACE_LARGE_PORTRAIT) ||
                    mDrawIdentifier.equals(MIGRATION_WORKSPACE_LANDSCAPE)) {
                int offset = DynamicGrid.pxFromDp(WORKSPACE_CIRCLE_Y_OFFSET_DPS, metrics);
                // Draw the outer circle
                eraseCanvas.drawCircle(pageIndicatorBounds.centerX(),
                        pageIndicatorBounds.centerY(),
                        DynamicGrid.pxFromDp(MIGRATION_WORKSPACE_OUTER_CIRCLE_RADIUS_DPS, metrics),
                        mBorderPaint);
                // Draw the inner circle
                mErasePaint.setAlpha(0);
                eraseCanvas.drawCircle(pageIndicatorBounds.centerX(),
                        pageIndicatorBounds.centerY(),
                        DynamicGrid.pxFromDp(MIGRATION_WORKSPACE_INNER_CIRCLE_RADIUS_DPS, metrics),
                        mErasePaint);
                canvas.drawBitmap(eraseBg, 0, 0, null);
                eraseCanvas.setBitmap(null);
                eraseBg = null;
            }
            canvas.restore();
        }

        // Draw the rest of the cling
        super.dispatchDraw(canvas);
    };
}