DeviceProfile.java revision a295048a69d35b5adc3f021c3d40c32700cc9629
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.launcher3;
18
19import android.appwidget.AppWidgetHostView;
20import android.content.ComponentName;
21import android.content.Context;
22import android.content.res.Resources;
23import android.graphics.Paint;
24import android.graphics.Paint.FontMetrics;
25import android.graphics.Point;
26import android.graphics.Rect;
27import android.util.DisplayMetrics;
28import android.view.Gravity;
29import android.view.View;
30import android.view.ViewGroup;
31import android.view.ViewGroup.LayoutParams;
32import android.view.ViewGroup.MarginLayoutParams;
33import android.widget.FrameLayout;
34import android.widget.LinearLayout;
35
36public class DeviceProfile {
37
38    public final InvariantDeviceProfile inv;
39
40    // Device properties
41    public final boolean isTablet;
42    public final boolean isLargeTablet;
43    public final boolean isPhone;
44    public final boolean transposeLayoutWithOrientation;
45
46    // Device properties in current orientation
47    public final boolean isLandscape;
48    public final int widthPx;
49    public final int heightPx;
50    public final int availableWidthPx;
51    public final int availableHeightPx;
52    /**
53     * The maximum amount of left/right workspace padding as a percentage of the screen width.
54     * To be clear, this means that up to 7% of the screen width can be used as left padding, and
55     * 7% of the screen width can be used as right padding.
56     */
57    private static final float MAX_HORIZONTAL_PADDING_PERCENT = 0.14f;
58
59    // Overview mode
60    private final int overviewModeMinIconZoneHeightPx;
61    private final int overviewModeMaxIconZoneHeightPx;
62    private final int overviewModeBarItemWidthPx;
63    private final int overviewModeBarSpacerWidthPx;
64    private final float overviewModeIconZoneRatio;
65
66    // Workspace
67    private int desiredWorkspaceLeftRightMarginPx;
68    public final int edgeMarginPx;
69    public final Rect defaultWidgetPadding;
70    private final int pageIndicatorHeightPx;
71    private final int defaultPageSpacingPx;
72    private float dragViewScale;
73
74    // Workspace icons
75    public int iconSizePx;
76    public int iconTextSizePx;
77    public int iconDrawablePaddingPx;
78    public int iconDrawablePaddingOriginalPx;
79
80    public int cellWidthPx;
81    public int cellHeightPx;
82
83    // Folder
84    public int folderBackgroundOffset;
85    public int folderIconSizePx;
86    public int folderCellWidthPx;
87    public int folderCellHeightPx;
88
89    // Hotseat
90    public int hotseatCellWidthPx;
91    public int hotseatCellHeightPx;
92    public int hotseatIconSizePx;
93    private int hotseatBarHeightNormalPx, hotseatBarHeightShortPx;
94    private int hotseatBarHeightPx; // One of the above.
95
96    // All apps
97    public int allAppsNumCols;
98    public int allAppsNumPredictiveCols;
99    public int allAppsButtonVisualSize;
100    public final int allAppsIconSizePx;
101    public final int allAppsIconTextSizePx;
102
103    // QSB
104    private int searchBarSpaceWidthPx;
105    private int searchBarSpaceHeightNormalPx, searchBarSpaceHeightTallPx;
106    private int searchBarSpaceHeightPx; // One of the above.
107    private int searchBarHeight = LauncherCallbacks.SEARCH_BAR_HEIGHT_NORMAL;
108
109    public DeviceProfile(Context context, InvariantDeviceProfile inv,
110            Point minSize, Point maxSize,
111            int width, int height, boolean isLandscape) {
112
113        this.inv = inv;
114        this.isLandscape = isLandscape;
115
116        Resources res = context.getResources();
117        DisplayMetrics dm = res.getDisplayMetrics();
118
119        // Constants from resources
120        isTablet = res.getBoolean(R.bool.is_tablet);
121        isLargeTablet = res.getBoolean(R.bool.is_large_tablet);
122        isPhone = !isTablet && !isLargeTablet;
123
124        // Some more constants
125        transposeLayoutWithOrientation =
126                res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);
127
128        ComponentName cn = new ComponentName(context.getPackageName(),
129                this.getClass().getName());
130        defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
131        edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
132        desiredWorkspaceLeftRightMarginPx = 2 * edgeMarginPx;
133        pageIndicatorHeightPx =
134                res.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height);
135        defaultPageSpacingPx =
136                res.getDimensionPixelSize(R.dimen.dynamic_grid_workspace_page_spacing);
137        overviewModeMinIconZoneHeightPx =
138                res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_min_icon_zone_height);
139        overviewModeMaxIconZoneHeightPx =
140                res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_max_icon_zone_height);
141        overviewModeBarItemWidthPx =
142                res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_bar_item_width);
143        overviewModeBarSpacerWidthPx =
144                res.getDimensionPixelSize(R.dimen.dynamic_grid_overview_bar_spacer_width);
145        overviewModeIconZoneRatio =
146                res.getInteger(R.integer.config_dynamic_grid_overview_icon_zone_percentage) / 100f;
147        iconDrawablePaddingOriginalPx =
148                res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
149
150        // AllApps uses the original non-scaled icon text size
151        allAppsIconTextSizePx = Utilities.pxFromDp(inv.iconTextSize, dm);
152
153        // AllApps uses the original non-scaled icon size
154        allAppsIconSizePx = Utilities.pxFromDp(inv.iconSize, dm);
155
156        // Determine sizes.
157        widthPx = width;
158        heightPx = height;
159        if (isLandscape) {
160            availableWidthPx = maxSize.x;
161            availableHeightPx = minSize.y;
162        } else {
163            availableWidthPx = minSize.x;
164            availableHeightPx = maxSize.y;
165        }
166
167        // Calculate the remaining vars
168        updateAvailableDimensions(dm, res);
169        computeAllAppsButtonSize(context);
170    }
171
172    /**
173     * Determine the exact visual footprint of the all apps button, taking into account scaling
174     * and internal padding of the drawable.
175     */
176    private void computeAllAppsButtonSize(Context context) {
177        Resources res = context.getResources();
178        float padding = res.getInteger(R.integer.config_allAppsButtonPaddingPercent) / 100f;
179        allAppsButtonVisualSize = (int) (hotseatIconSizePx * (1 - padding)) - context.getResources()
180                        .getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
181    }
182
183    private void updateAvailableDimensions(DisplayMetrics dm, Resources res) {
184        // Check to see if the icons fit in the new available height.  If not, then we need to
185        // shrink the icon size.
186        float scale = 1f;
187        int drawablePadding = iconDrawablePaddingOriginalPx;
188        updateIconSize(1f, drawablePadding, res, dm);
189        float usedHeight = (cellHeightPx * inv.numRows);
190
191        // We only care about the top and bottom workspace padding, which is not affected by RTL.
192        Rect workspacePadding = getWorkspacePadding(false /* isLayoutRtl */);
193        int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom);
194        if (usedHeight > maxHeight) {
195            scale = maxHeight / usedHeight;
196            drawablePadding = 0;
197        }
198        updateIconSize(scale, drawablePadding, res, dm);
199    }
200
201    private void updateIconSize(float scale, int drawablePadding, Resources res,
202                                DisplayMetrics dm) {
203        iconSizePx = (int) (Utilities.pxFromDp(inv.iconSize, dm) * scale);
204        iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale);
205        iconDrawablePaddingPx = drawablePadding;
206        hotseatIconSizePx = (int) (Utilities.pxFromDp(inv.hotseatIconSize, dm) * scale);
207
208        // Search Bar
209        searchBarSpaceWidthPx = Math.min(widthPx,
210                res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width));
211        searchBarSpaceHeightNormalPx = getSearchBarTopOffset()
212                + res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height);
213        searchBarSpaceHeightTallPx = getSearchBarTopOffset()
214                + res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height_tall);
215
216        // Calculate the actual text height
217        Paint textPaint = new Paint();
218        textPaint.setTextSize(iconTextSizePx);
219        FontMetrics fm = textPaint.getFontMetrics();
220        cellWidthPx = iconSizePx;
221        cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top);
222        final float scaleDps = res.getDimensionPixelSize(R.dimen.dragViewScale);
223        dragViewScale = (iconSizePx + scaleDps) / iconSizePx;
224
225        // Hotseat
226        hotseatBarHeightNormalPx = iconSizePx + 4 * edgeMarginPx;
227        hotseatBarHeightShortPx = iconSizePx + 2 * edgeMarginPx;
228        hotseatCellWidthPx = iconSizePx;
229        hotseatCellHeightPx = iconSizePx;
230
231        // Folder
232        folderCellWidthPx = Math.min(cellWidthPx + 6 * edgeMarginPx,
233                (availableWidthPx - 4 * edgeMarginPx) / inv.numFolderColumns);
234        folderCellHeightPx = cellHeightPx + edgeMarginPx;
235        folderBackgroundOffset = -edgeMarginPx;
236        folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
237    }
238
239    /**
240     * @param recyclerViewWidth the available width of the AllAppsRecyclerView
241     */
242    public void updateAppsViewNumCols(Resources res, int recyclerViewWidth) {
243        int appsViewLeftMarginPx =
244                res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
245        int allAppsCellWidthGap =
246                res.getDimensionPixelSize(R.dimen.all_apps_icon_width_gap);
247        int availableAppsWidthPx = (recyclerViewWidth > 0) ? recyclerViewWidth : availableWidthPx;
248        int numAppsCols = (availableAppsWidthPx - appsViewLeftMarginPx) /
249                (allAppsIconSizePx + allAppsCellWidthGap);
250        int numPredictiveAppCols = Math.max(inv.minAllAppsPredictionColumns, numAppsCols);
251        allAppsNumCols = numAppsCols;
252        allAppsNumPredictiveCols = numPredictiveAppCols;
253    }
254
255    /** Returns the search bar top offset */
256    private int getSearchBarTopOffset() {
257        if (isTablet && !isVerticalBarLayout()) {
258            return 4 * edgeMarginPx;
259        } else {
260            return 2 * edgeMarginPx;
261        }
262    }
263
264    /** Returns the search bar bounds in the current orientation */
265    public Rect getSearchBarBounds(boolean isLayoutRtl) {
266        Rect bounds = new Rect();
267        if (isVerticalBarLayout()) {
268            if (isLayoutRtl) {
269                bounds.set(availableWidthPx - searchBarSpaceHeightNormalPx, edgeMarginPx,
270                        availableWidthPx, availableHeightPx - edgeMarginPx);
271            } else {
272                bounds.set(0, edgeMarginPx, searchBarSpaceHeightNormalPx,
273                        availableHeightPx - edgeMarginPx);
274            }
275        } else {
276            if (isTablet) {
277                // Pad the left and right of the workspace to ensure consistent spacing
278                // between all icons
279                int width = getCurrentWidth();
280                // XXX: If the icon size changes across orientations, we will have to take
281                //      that into account here too.
282                int gap = (int) ((width - 2 * edgeMarginPx -
283                        (inv.numColumns * cellWidthPx)) / (2 * (inv.numColumns + 1)));
284                bounds.set(edgeMarginPx + gap, getSearchBarTopOffset(),
285                        availableWidthPx - (edgeMarginPx + gap),
286                        searchBarSpaceHeightPx);
287            } else {
288                bounds.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
289                        getSearchBarTopOffset(),
290                        availableWidthPx - (desiredWorkspaceLeftRightMarginPx -
291                        defaultWidgetPadding.right), searchBarSpaceHeightPx);
292            }
293        }
294        return bounds;
295    }
296
297    /** Returns the workspace padding in the specified orientation */
298    Rect getWorkspacePadding(boolean isLayoutRtl) {
299        Rect searchBarBounds = getSearchBarBounds(isLayoutRtl);
300        Rect padding = new Rect();
301        if (isVerticalBarLayout()) {
302            // Pad the left and right of the workspace with search/hotseat bar sizes
303            if (isLayoutRtl) {
304                padding.set(hotseatBarHeightNormalPx, edgeMarginPx,
305                        searchBarBounds.width(), edgeMarginPx);
306            } else {
307                padding.set(searchBarBounds.width(), edgeMarginPx,
308                        hotseatBarHeightNormalPx, edgeMarginPx);
309            }
310        } else {
311            if (isTablet) {
312                // Pad the left and right of the workspace to ensure consistent spacing
313                // between all icons
314                float gapScale = 1f + (dragViewScale - 1f) / 2f;
315                int width = getCurrentWidth();
316                int height = getCurrentHeight();
317                int paddingTop = searchBarBounds.bottom;
318                int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx;
319                // The amount of screen space available for left/right padding.
320                int availablePaddingX = Math.max(0, width - (int) ((inv.numColumns * cellWidthPx) +
321                        ((inv.numColumns - 1) * gapScale * cellWidthPx)));
322                availablePaddingX = (int) Math.min(availablePaddingX,
323                            width * MAX_HORIZONTAL_PADDING_PERCENT);
324                int availablePaddingY = Math.max(0, height - paddingTop - paddingBottom
325                        - (int) (2 * inv.numRows * cellHeightPx));
326                padding.set(availablePaddingX / 2, paddingTop + availablePaddingY / 2,
327                        availablePaddingX / 2, paddingBottom + availablePaddingY / 2);
328            } else {
329                // Pad the top and bottom of the workspace with search/hotseat bar sizes
330                padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left,
331                        searchBarBounds.bottom,
332                        desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.right,
333                        hotseatBarHeightPx + pageIndicatorHeightPx);
334            }
335        }
336        return padding;
337    }
338
339    private int getWorkspacePageSpacing(boolean isLayoutRtl) {
340        if (isVerticalBarLayout() || isLargeTablet) {
341            // In landscape mode the page spacing is set to the default.
342            return defaultPageSpacingPx;
343        } else {
344            // In portrait, we want the pages spaced such that there is no
345            // overhang of the previous / next page into the current page viewport.
346            // We assume symmetrical padding in portrait mode.
347            return Math.max(defaultPageSpacingPx, 2 * getWorkspacePadding(isLayoutRtl).left);
348        }
349    }
350
351    int getOverviewModeButtonBarHeight() {
352        int zoneHeight = (int) (overviewModeIconZoneRatio * availableHeightPx);
353        zoneHeight = Math.min(overviewModeMaxIconZoneHeightPx,
354                Math.max(overviewModeMinIconZoneHeightPx, zoneHeight));
355        return zoneHeight;
356    }
357
358    // The rect returned will be extended to below the system ui that covers the workspace
359    Rect getHotseatRect() {
360        if (isVerticalBarLayout()) {
361            return new Rect(availableWidthPx - hotseatBarHeightNormalPx, 0,
362                    Integer.MAX_VALUE, availableHeightPx);
363        } else {
364            return new Rect(0, availableHeightPx - hotseatBarHeightPx,
365                    availableWidthPx, Integer.MAX_VALUE);
366        }
367    }
368
369    public static int calculateCellWidth(int width, int countX) {
370        return width / countX;
371    }
372    public static int calculateCellHeight(int height, int countY) {
373        return height / countY;
374    }
375
376    /**
377     * When {@code true}, the device is in landscape mode and the hotseat is on the right column.
378     * When {@code false}, either device is in portrait mode or the device is in landscape mode and
379     * the hotseat is on the bottom row.
380     */
381    boolean isVerticalBarLayout() {
382        return isLandscape && transposeLayoutWithOrientation;
383    }
384
385    boolean shouldFadeAdjacentWorkspaceScreens() {
386        return isVerticalBarLayout() || isLargeTablet;
387    }
388
389    private int getVisibleChildCount(ViewGroup parent) {
390        int visibleChildren = 0;
391        for (int i = 0; i < parent.getChildCount(); i++) {
392            if (parent.getChildAt(i).getVisibility() != View.GONE) {
393                visibleChildren++;
394            }
395        }
396        return visibleChildren;
397    }
398
399    public void layout(Launcher launcher) {
400        FrameLayout.LayoutParams lp;
401        boolean hasVerticalBarLayout = isVerticalBarLayout();
402        final boolean isLayoutRtl = Utilities.isRtl(launcher.getResources());
403
404        // Layout the search bar space
405        View searchBar = launcher.getSearchDropTargetBar();
406        lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
407        searchBarHeight = launcher.getSearchBarHeight();
408        if (searchBarHeight == LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL) {
409            hotseatBarHeightPx = hotseatBarHeightShortPx;
410            searchBarSpaceHeightPx = searchBarSpaceHeightTallPx;
411        } else {
412            hotseatBarHeightPx = hotseatBarHeightNormalPx;
413            searchBarSpaceHeightPx = searchBarSpaceHeightNormalPx;
414        }
415        if (hasVerticalBarLayout) {
416            // Vertical search bar space -- The search bar is fixed in the layout to be on the left
417            //                              of the screen regardless of RTL
418            lp.gravity = Gravity.LEFT;
419            lp.width = searchBarSpaceHeightNormalPx;
420
421            LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar);
422            targets.setOrientation(LinearLayout.VERTICAL);
423            FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams();
424            targetsLp.gravity = Gravity.TOP;
425            targetsLp.height = LayoutParams.WRAP_CONTENT;
426
427        } else {
428            // Horizontal search bar space
429            lp.gravity = Gravity.TOP;
430            lp.height = searchBarSpaceHeightPx;
431
432            LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar);
433            targets.getLayoutParams().width = searchBarSpaceWidthPx;
434        }
435        searchBar.setLayoutParams(lp);
436
437        // Layout the workspace
438        PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace);
439        lp = (FrameLayout.LayoutParams) workspace.getLayoutParams();
440        lp.gravity = Gravity.CENTER;
441        Rect padding = getWorkspacePadding(isLayoutRtl);
442        workspace.setLayoutParams(lp);
443        workspace.setPadding(padding.left, padding.top, padding.right, padding.bottom);
444        workspace.setPageSpacing(getWorkspacePageSpacing(isLayoutRtl));
445
446        // Layout the hotseat
447        View hotseat = launcher.findViewById(R.id.hotseat);
448        lp = (FrameLayout.LayoutParams) hotseat.getLayoutParams();
449        // We want the edges of the hotseat to line up with the edges of the workspace, but the
450        // icons in the hotseat are a different size, and so don't line up perfectly. To account for
451        // this, we pad the left and right of the hotseat with half of the difference of a workspace
452        // cell vs a hotseat cell.
453        float workspaceCellWidth = (float) getCurrentWidth() / inv.numColumns;
454        float hotseatCellWidth = (float) getCurrentWidth() / inv.numHotseatIcons;
455        int hotseatAdjustment = Math.round((workspaceCellWidth - hotseatCellWidth) / 2);
456        if (hasVerticalBarLayout) {
457            // Vertical hotseat -- The hotseat is fixed in the layout to be on the right of the
458            //                     screen regardless of RTL
459            lp.gravity = Gravity.RIGHT;
460            lp.width = hotseatBarHeightNormalPx;
461            lp.height = LayoutParams.MATCH_PARENT;
462            hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx);
463        } else if (isTablet) {
464            // Pad the hotseat with the workspace padding calculated above
465            lp.gravity = Gravity.BOTTOM;
466            lp.width = LayoutParams.MATCH_PARENT;
467            lp.height = hotseatBarHeightPx;
468            hotseat.findViewById(R.id.layout).setPadding(
469                    hotseatAdjustment + padding.left, 0,
470                    hotseatAdjustment + padding.right, 2 * edgeMarginPx);
471        } else {
472            // For phones, layout the hotseat without any bottom margin
473            // to ensure that we have space for the folders
474            lp.gravity = Gravity.BOTTOM;
475            lp.width = LayoutParams.MATCH_PARENT;
476            lp.height = hotseatBarHeightPx;
477            hotseat.findViewById(R.id.layout).setPadding(
478                    hotseatAdjustment + padding.left, 0,
479                    hotseatAdjustment + padding.right, 0);
480        }
481        hotseat.setLayoutParams(lp);
482
483        // Layout the page indicators
484        View pageIndicator = launcher.findViewById(R.id.page_indicator);
485        if (pageIndicator != null) {
486            if (hasVerticalBarLayout) {
487                // Hide the page indicators when we have vertical search/hotseat
488                pageIndicator.setVisibility(View.GONE);
489            } else {
490                // Put the page indicators above the hotseat
491                lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
492                lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
493                lp.width = LayoutParams.WRAP_CONTENT;
494                lp.height = LayoutParams.WRAP_CONTENT;
495                lp.bottomMargin = hotseatBarHeightPx;
496                pageIndicator.setLayoutParams(lp);
497            }
498        }
499
500        // Layout the Overview Mode
501        ViewGroup overviewMode = launcher.getOverviewPanel();
502        if (overviewMode != null) {
503            int overviewButtonBarHeight = getOverviewModeButtonBarHeight();
504            lp = (FrameLayout.LayoutParams) overviewMode.getLayoutParams();
505            lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
506
507            int visibleChildCount = getVisibleChildCount(overviewMode);
508            int totalItemWidth = visibleChildCount * overviewModeBarItemWidthPx;
509            int maxWidth = totalItemWidth + (visibleChildCount-1) * overviewModeBarSpacerWidthPx;
510
511            lp.width = Math.min(availableWidthPx, maxWidth);
512            lp.height = overviewButtonBarHeight;
513            overviewMode.setLayoutParams(lp);
514
515            if (lp.width > totalItemWidth && visibleChildCount > 1) {
516                // We have enough space. Lets add some margin too.
517                int margin = (lp.width - totalItemWidth) / (visibleChildCount-1);
518                View lastChild = null;
519
520                // Set margin of all visible children except the last visible child
521                for (int i = 0; i < visibleChildCount; i++) {
522                    if (lastChild != null) {
523                        MarginLayoutParams clp = (MarginLayoutParams) lastChild.getLayoutParams();
524                        if (isLayoutRtl) {
525                            clp.leftMargin = margin;
526                        } else {
527                            clp.rightMargin = margin;
528                        }
529                        lastChild.setLayoutParams(clp);
530                        lastChild = null;
531                    }
532                    View thisChild = overviewMode.getChildAt(i);
533                    if (thisChild.getVisibility() != View.GONE) {
534                        lastChild = thisChild;
535                    }
536                }
537            }
538        }
539    }
540
541    private int getCurrentWidth() {
542        return isLandscape
543                ? Math.max(widthPx, heightPx)
544                : Math.min(widthPx, heightPx);
545    }
546
547    private int getCurrentHeight() {
548        return isLandscape
549                ? Math.min(widthPx, heightPx)
550                : Math.max(widthPx, heightPx);
551    }
552}
553