blob: f43af615f1afb5049f540462f12b1a090c0a37bb [file] [log] [blame]
Winson Chung5f8afe62013-08-12 16:19:28 -07001/*
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.content.res.Configuration;
20import android.content.res.Resources;
21import android.graphics.Paint;
22import android.graphics.PointF;
23import android.graphics.Paint.FontMetrics;
24import android.graphics.Rect;
25import android.util.DisplayMetrics;
26import android.util.TypedValue;
27import android.view.Gravity;
28import android.view.View;
29import android.view.ViewGroup.LayoutParams;
30import android.widget.FrameLayout;
31
32import java.util.ArrayList;
33import java.util.Collections;
34import java.util.Comparator;
35
36
37class DeviceProfileQuery {
38 float widthDps;
39 float heightDps;
40 float value;
41 PointF dimens;
42
43 DeviceProfileQuery(float w, float h, float v) {
44 widthDps = w;
45 heightDps = h;
46 value = v;
47 dimens = new PointF(w, h);
48 }
49}
50
51class DeviceProfile {
52 String name;
53 float minWidthDps;
54 float minHeightDps;
55 float numRows;
56 float numColumns;
57 float iconSize;
58 float iconTextSize;
59 float numHotseatIcons;
60 float hotseatIconSize;
61
62 boolean isLandscape;
63 boolean isTablet;
64 boolean isLargeTablet;
65 boolean transposeLayoutWithOrientation;
66
67 int edgeMarginPx;
68
69 int widthPx;
70 int heightPx;
Winson Chung892c74d2013-08-22 16:15:50 -070071 int availableWidthPx;
72 int availableHeightPx;
Winson Chung5f8afe62013-08-12 16:19:28 -070073 int iconSizePx;
74 int iconTextSizePx;
75 int cellWidthPx;
76 int cellHeightPx;
77 int folderBackgroundOffset;
78 int folderIconSizePx;
79 int folderCellWidthPx;
80 int folderCellHeightPx;
81 int hotseatCellWidthPx;
82 int hotseatCellHeightPx;
83 int hotseatIconSizePx;
84 int hotseatBarHeightPx;
Winson Chungc58497e2013-09-03 17:48:37 -070085 int hotseatAllAppsRank;
86 int allAppsNumRows;
87 int allAppsNumCols;
Winson Chung5f8afe62013-08-12 16:19:28 -070088 int searchBarSpaceWidthPx;
89 int searchBarSpaceMaxWidthPx;
90 int searchBarSpaceHeightPx;
91 int searchBarHeightPx;
92 int pageIndicatorHeightPx;
93
94 DeviceProfile(String n, float w, float h, float r, float c,
95 float is, float its, float hs, float his) {
Winson Chungc58497e2013-09-03 17:48:37 -070096 // Ensure that we have an odd number of hotseat items (since we need to place all apps)
97 if (!AppsCustomizePagedView.DISABLE_ALL_APPS && hs % 2 == 0) {
98 throw new RuntimeException("All Device Profiles must have an odd number of hotseat spaces");
99 }
100
Winson Chung5f8afe62013-08-12 16:19:28 -0700101 name = n;
102 minWidthDps = w;
103 minHeightDps = h;
104 numRows = r;
105 numColumns = c;
106 iconSize = is;
107 iconTextSize = its;
108 numHotseatIcons = hs;
109 hotseatIconSize = his;
110 }
111
112 DeviceProfile(ArrayList<DeviceProfile> profiles,
Winson Chung892c74d2013-08-22 16:15:50 -0700113 float minWidth, float minHeight,
Winson Chung5f8afe62013-08-12 16:19:28 -0700114 int wPx, int hPx,
Winson Chung892c74d2013-08-22 16:15:50 -0700115 int awPx, int ahPx,
Winson Chung5f8afe62013-08-12 16:19:28 -0700116 Resources resources) {
117 DisplayMetrics dm = resources.getDisplayMetrics();
118 ArrayList<DeviceProfileQuery> points =
119 new ArrayList<DeviceProfileQuery>();
120 transposeLayoutWithOrientation =
121 resources.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);
Winson Chung5f8afe62013-08-12 16:19:28 -0700122 minWidthDps = minWidth;
123 minHeightDps = minHeight;
124
125 edgeMarginPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
126 pageIndicatorHeightPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_page_indicator_height);
127
128 // Interpolate the rows
129 for (DeviceProfile p : profiles) {
130 points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.numRows));
131 }
132 numRows = Math.round(invDistWeightedInterpolate(minWidth, minHeight, points));
133 // Interpolate the columns
134 points.clear();
135 for (DeviceProfile p : profiles) {
136 points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.numColumns));
137 }
138 numColumns = Math.round(invDistWeightedInterpolate(minWidth, minHeight, points));
139 // Interpolate the icon size
140 points.clear();
141 for (DeviceProfile p : profiles) {
142 points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.iconSize));
143 }
144 iconSize = invDistWeightedInterpolate(minWidth, minHeight, points);
Winson Chung892c74d2013-08-22 16:15:50 -0700145 iconSizePx = DynamicGrid.pxFromDp(iconSize, dm);
146
Winson Chung5f8afe62013-08-12 16:19:28 -0700147 // Interpolate the icon text size
148 points.clear();
149 for (DeviceProfile p : profiles) {
150 points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.iconTextSize));
151 }
152 iconTextSize = invDistWeightedInterpolate(minWidth, minHeight, points);
Winson Chung892c74d2013-08-22 16:15:50 -0700153 iconTextSizePx = DynamicGrid.pxFromSp(iconTextSize, dm);
154
Winson Chung5f8afe62013-08-12 16:19:28 -0700155 // Interpolate the hotseat size
156 points.clear();
157 for (DeviceProfile p : profiles) {
158 points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.numHotseatIcons));
159 }
160 numHotseatIcons = Math.round(invDistWeightedInterpolate(minWidth, minHeight, points));
161 // Interpolate the hotseat icon size
162 points.clear();
163 for (DeviceProfile p : profiles) {
164 points.add(new DeviceProfileQuery(p.minWidthDps, p.minHeightDps, p.hotseatIconSize));
165 }
Winson Chung5f8afe62013-08-12 16:19:28 -0700166 // Hotseat
167 hotseatIconSize = invDistWeightedInterpolate(minWidth, minHeight, points);
Winson Chung892c74d2013-08-22 16:15:50 -0700168 hotseatIconSizePx = DynamicGrid.pxFromDp(hotseatIconSize, dm);
Winson Chungc58497e2013-09-03 17:48:37 -0700169 hotseatAllAppsRank = (int) (numColumns / 2);
Winson Chung892c74d2013-08-22 16:15:50 -0700170
171 // Calculate other vars based on Configuration
172 updateFromConfiguration(resources, wPx, hPx, awPx, ahPx);
Winson Chung5f8afe62013-08-12 16:19:28 -0700173
174 // Search Bar
175 searchBarSpaceMaxWidthPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width);
176 searchBarHeightPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height);
177 searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx);
178 searchBarSpaceHeightPx = searchBarHeightPx + 2 * edgeMarginPx;
179
180 // Calculate the actual text height
181 Paint textPaint = new Paint();
182 textPaint.setTextSize(iconTextSizePx);
183 FontMetrics fm = textPaint.getFontMetrics();
184 cellWidthPx = iconSizePx;
185 cellHeightPx = iconSizePx + (int) Math.ceil(fm.bottom - fm.top);
186
Winson Chung892c74d2013-08-22 16:15:50 -0700187 // At this point, if the cells do not fit into the available height, then we need
188 // to shrink the icon size
189 /*
190 Rect padding = getWorkspacePadding(isLandscape ?
191 CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
192 int h = (int) (numRows * cellHeightPx) + padding.top + padding.bottom;
193 if (h > availableHeightPx) {
194 float delta = h - availableHeightPx;
195 int deltaPx = (int) Math.ceil(delta / numRows);
196 iconSizePx -= deltaPx;
197 iconSize = DynamicGrid.dpiFromPx(iconSizePx, dm);
198 cellWidthPx = iconSizePx;
199 cellHeightPx = iconSizePx + (int) Math.ceil(fm.bottom - fm.top);
200 }
201 */
202
203 // Hotseat
204 hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx;
205 hotseatCellWidthPx = iconSizePx;
206 hotseatCellHeightPx = iconSizePx;
207
Winson Chung5f8afe62013-08-12 16:19:28 -0700208 // Folder
209 folderCellWidthPx = cellWidthPx + 3 * edgeMarginPx;
210 folderCellHeightPx = cellHeightPx + edgeMarginPx;
211 folderBackgroundOffset = -edgeMarginPx;
212 folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
213 }
214
Winson Chung892c74d2013-08-22 16:15:50 -0700215 void updateFromConfiguration(Resources resources, int wPx, int hPx,
216 int awPx, int ahPx) {
Winson Chung5f8afe62013-08-12 16:19:28 -0700217 isLandscape = (resources.getConfiguration().orientation ==
218 Configuration.ORIENTATION_LANDSCAPE);
219 isTablet = resources.getBoolean(R.bool.is_tablet);
220 isLargeTablet = resources.getBoolean(R.bool.is_large_tablet);
221 widthPx = wPx;
222 heightPx = hPx;
Winson Chung892c74d2013-08-22 16:15:50 -0700223 availableWidthPx = awPx;
224 availableHeightPx = ahPx;
Winson Chungc58497e2013-09-03 17:48:37 -0700225
226 if (isLandscape) {
227 allAppsNumRows = (int) numRows - 1;
228 } else {
229 allAppsNumRows = (int) numRows + 1;
230 }
231 Rect padding = getWorkspacePadding(isLandscape ?
232 CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
233 int pageIndicatorOffset =
234 resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset);
235 allAppsNumRows = (availableHeightPx - pageIndicatorOffset - 4 * edgeMarginPx) /
236 (iconSizePx + iconTextSizePx + 2 * edgeMarginPx);
237 allAppsNumCols = (availableWidthPx - padding.left - padding.right - 2 * edgeMarginPx) /
238 (iconSizePx + 2 * edgeMarginPx);
Winson Chung5f8afe62013-08-12 16:19:28 -0700239 }
240
241 private float dist(PointF p0, PointF p1) {
242 return (float) Math.sqrt((p1.x - p0.x)*(p1.x-p0.x) +
243 (p1.y-p0.y)*(p1.y-p0.y));
244 }
245
246 private float weight(PointF a, PointF b,
247 float pow) {
248 float d = dist(a, b);
249 if (d == 0f) {
250 return Float.POSITIVE_INFINITY;
251 }
252 return (float) (1f / Math.pow(d, pow));
253 }
254
255 private float invDistWeightedInterpolate(float width, float height,
256 ArrayList<DeviceProfileQuery> points) {
257 float sum = 0;
258 float weights = 0;
259 float pow = 5;
260 float kNearestNeighbors = 3;
261 final PointF xy = new PointF(width, height);
262
263 ArrayList<DeviceProfileQuery> pointsByNearness = points;
264 Collections.sort(pointsByNearness, new Comparator<DeviceProfileQuery>() {
265 public int compare(DeviceProfileQuery a, DeviceProfileQuery b) {
266 return (int) (dist(xy, a.dimens) - dist(xy, b.dimens));
267 }
268 });
269
270 for (int i = 0; i < pointsByNearness.size(); ++i) {
271 DeviceProfileQuery p = pointsByNearness.get(i);
272 if (i < kNearestNeighbors) {
273 float w = weight(xy, p.dimens, pow);
274 if (w == Float.POSITIVE_INFINITY) {
275 return p.value;
276 }
277 weights += w;
278 }
279 }
280
281 for (int i = 0; i < pointsByNearness.size(); ++i) {
282 DeviceProfileQuery p = pointsByNearness.get(i);
283 if (i < kNearestNeighbors) {
284 float w = weight(xy, p.dimens, pow);
285 sum += w * p.value / weights;
286 }
287 }
288
289 return sum;
290 }
291
292 Rect getWorkspacePadding(int orientation) {
293 Rect padding = new Rect();
294 if (orientation == CellLayout.LANDSCAPE &&
295 transposeLayoutWithOrientation) {
296 // Pad the left and right of the workspace with search/hotseat bar sizes
297 padding.set(searchBarSpaceHeightPx, edgeMarginPx,
298 hotseatBarHeightPx, edgeMarginPx);
299 } else {
300 if (isTablet()) {
301 // Pad the left and right of the workspace to ensure consistent spacing
302 // between all icons
303 int width = (orientation == CellLayout.LANDSCAPE)
304 ? Math.max(widthPx, heightPx)
305 : Math.min(widthPx, heightPx);
306 // XXX: If the icon size changes across orientations, we will have to take
307 // that into account here too.
308 int gap = (int) ((width - 2 * edgeMarginPx -
309 (numColumns * cellWidthPx)) / (2 * (numColumns + 1)));
310 padding.set(edgeMarginPx + gap,
311 searchBarSpaceHeightPx,
312 edgeMarginPx + gap,
313 hotseatBarHeightPx + pageIndicatorHeightPx);
314 } else {
315 // Pad the top and bottom of the workspace with search/hotseat bar sizes
316 padding.set(edgeMarginPx,
317 searchBarSpaceHeightPx,
318 edgeMarginPx,
319 hotseatBarHeightPx + pageIndicatorHeightPx);
320 }
321 }
322 return padding;
323 }
324
325 int calculateCellWidth(int width, int countX) {
326 return width / countX;
327 }
328 int calculateCellHeight(int height, int countY) {
329 return height / countY;
330 }
331
332 boolean isTablet() {
333 return isTablet;
334 }
335
336 boolean isLargeTablet() {
337 return isLargeTablet;
338 }
339
340 public void layout(Launcher launcher) {
341 FrameLayout.LayoutParams lp;
342 Resources res = launcher.getResources();
343 boolean hasVerticalBarLayout = isLandscape &&
344 res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);
345
346 // Layout the search bar space
347 View searchBarSpace = launcher.findViewById(R.id.qsb_bar);
348 lp = (FrameLayout.LayoutParams) searchBarSpace.getLayoutParams();
349 if (hasVerticalBarLayout) {
350 // Vertical search bar
351 lp.gravity = Gravity.TOP | Gravity.LEFT;
352 lp.width = searchBarSpaceHeightPx;
353 lp.height = LayoutParams.MATCH_PARENT;
354 searchBarSpace.setPadding(
355 0, 2 * edgeMarginPx, 0,
356 2 * edgeMarginPx);
357 } else {
358 // Horizontal search bar
359 lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
360 lp.width = searchBarSpaceWidthPx;
361 lp.height = searchBarSpaceHeightPx;
362 searchBarSpace.setPadding(
363 2 * edgeMarginPx,
364 2 * edgeMarginPx,
365 2 * edgeMarginPx, 0);
366 }
367 searchBarSpace.setLayoutParams(lp);
368
369 // Layout the search bar
Cristina Stancu476493b2013-08-07 17:20:14 +0100370 View searchBar = launcher.getQsbBar();
Winson Chung5f8afe62013-08-12 16:19:28 -0700371 lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
372 lp.width = LayoutParams.MATCH_PARENT;
373 lp.height = LayoutParams.MATCH_PARENT;
374 searchBar.setLayoutParams(lp);
375
376 // Layout the voice proxy
377 View voiceButtonProxy = launcher.findViewById(R.id.voice_button_proxy);
378 if (voiceButtonProxy != null) {
379 if (hasVerticalBarLayout) {
380 // TODO: MOVE THIS INTO SEARCH BAR MEASURE
381 } else {
382 lp = (FrameLayout.LayoutParams) voiceButtonProxy.getLayoutParams();
383 lp.gravity = Gravity.TOP | Gravity.END;
384 lp.width = (widthPx - searchBarSpaceWidthPx) / 2 +
385 2 * iconSizePx;
386 lp.height = searchBarSpaceHeightPx;
387 }
388 }
389
390 // Layout the workspace
391 View workspace = launcher.findViewById(R.id.workspace);
392 lp = (FrameLayout.LayoutParams) workspace.getLayoutParams();
393 lp.gravity = Gravity.CENTER;
394 Rect padding = getWorkspacePadding(isLandscape
395 ? CellLayout.LANDSCAPE
396 : CellLayout.PORTRAIT);
397 workspace.setPadding(padding.left, padding.top,
398 padding.right, padding.bottom);
399 workspace.setLayoutParams(lp);
400
401 // Layout the hotseat
402 View hotseat = launcher.findViewById(R.id.hotseat);
403 lp = (FrameLayout.LayoutParams) hotseat.getLayoutParams();
404 if (hasVerticalBarLayout) {
405 // Vertical hotseat
406 lp.gravity = Gravity.RIGHT;
407 lp.width = hotseatBarHeightPx;
408 lp.height = LayoutParams.MATCH_PARENT;
409 hotseat.setPadding(0, 2 * edgeMarginPx,
410 2 * edgeMarginPx, 2 * edgeMarginPx);
411 } else if (isTablet()) {
412 // Pad the hotseat with the grid gap calculated above
413 int gridGap = (int) ((widthPx - 2 * edgeMarginPx -
414 (numColumns * cellWidthPx)) / (2 * (numColumns + 1)));
415 int gridWidth = (int) ((numColumns * cellWidthPx) +
416 ((numColumns - 1) * gridGap));
417 int hotseatGap = (int) Math.max(0,
418 (gridWidth - (numHotseatIcons * hotseatCellWidthPx))
419 / (numHotseatIcons - 1));
420 lp.gravity = Gravity.BOTTOM;
421 lp.width = LayoutParams.MATCH_PARENT;
422 lp.height = hotseatBarHeightPx;
423 hotseat.setPadding(2 * edgeMarginPx + gridGap + hotseatGap, 0,
424 2 * edgeMarginPx + gridGap + hotseatGap,
425 2 * edgeMarginPx);
426 } else {
427 // For phones, layout the hotseat without any bottom margin
428 // to ensure that we have space for the folders
429 lp.gravity = Gravity.BOTTOM;
430 lp.width = LayoutParams.MATCH_PARENT;
431 lp.height = hotseatBarHeightPx;
432 hotseat.setPadding(2 * edgeMarginPx, 0,
433 2 * edgeMarginPx, 0);
434 }
435 hotseat.setLayoutParams(lp);
436
437 // Layout the page indicators
438 View pageIndicator = launcher.findViewById(R.id.page_indicator);
439 if (pageIndicator != null) {
440 if (hasVerticalBarLayout) {
441 // Hide the page indicators when we have vertical search/hotseat
442 pageIndicator.setVisibility(View.GONE);
443 } else {
444 // Put the page indicators above the hotseat
445 lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
446 lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
447 lp.width = LayoutParams.WRAP_CONTENT;
448 lp.height = pageIndicatorHeightPx;
449 lp.bottomMargin = hotseatBarHeightPx;
450 pageIndicator.setLayoutParams(lp);
451 }
452 }
453 }
454}
455
456public class DynamicGrid {
457 @SuppressWarnings("unused")
458 private static final String TAG = "DynamicGrid";
459
460 private DeviceProfile mProfile;
461 private float mMinWidth;
462 private float mMinHeight;
463
Winson Chung892c74d2013-08-22 16:15:50 -0700464 public static float dpiFromPx(int size, DisplayMetrics metrics){
Winson Chung5f8afe62013-08-12 16:19:28 -0700465 float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
Winson Chung892c74d2013-08-22 16:15:50 -0700466 return (size / densityRatio);
467 }
468 public static int pxFromDp(float size, DisplayMetrics metrics) {
469 return (int) Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
470 size, metrics));
471 }
472 public static int pxFromSp(float size, DisplayMetrics metrics) {
473 return (int) Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
474 size, metrics));
Winson Chung5f8afe62013-08-12 16:19:28 -0700475 }
476
477 public DynamicGrid(Resources resources, int minWidthPx, int minHeightPx,
Winson Chung892c74d2013-08-22 16:15:50 -0700478 int widthPx, int heightPx,
479 int awPx, int ahPx) {
Winson Chung5f8afe62013-08-12 16:19:28 -0700480 DisplayMetrics dm = resources.getDisplayMetrics();
481 ArrayList<DeviceProfile> deviceProfiles =
482 new ArrayList<DeviceProfile>();
Winson Chungc58497e2013-09-03 17:48:37 -0700483 boolean hasAA = !AppsCustomizePagedView.DISABLE_ALL_APPS;
Winson Chung5f8afe62013-08-12 16:19:28 -0700484 // Our phone profiles include the bar sizes in each orientation
485 deviceProfiles.add(new DeviceProfile("Super Short Stubby",
Winson Chungc58497e2013-09-03 17:48:37 -0700486 255, 300, 2, 3, 48, 12, (hasAA ? 5 : 4), 48));
Winson Chung5f8afe62013-08-12 16:19:28 -0700487 deviceProfiles.add(new DeviceProfile("Shorter Stubby",
Winson Chungc58497e2013-09-03 17:48:37 -0700488 255, 400, 3, 3, 48, 12, (hasAA ? 5 : 4), 48));
Winson Chung5f8afe62013-08-12 16:19:28 -0700489 deviceProfiles.add(new DeviceProfile("Short Stubby",
Winson Chungc58497e2013-09-03 17:48:37 -0700490 275, 420, 3, 4, 48, 12, (hasAA ? 5 : 4), 48));
Winson Chung5f8afe62013-08-12 16:19:28 -0700491 deviceProfiles.add(new DeviceProfile("Stubby",
Winson Chungc58497e2013-09-03 17:48:37 -0700492 255, 450, 3, 4, 48, 12, (hasAA ? 5 : 4), 48));
Winson Chung5f8afe62013-08-12 16:19:28 -0700493 deviceProfiles.add(new DeviceProfile("Nexus S",
Winson Chungc58497e2013-09-03 17:48:37 -0700494 296, 491.33f, 4, 4, 48, 12, (hasAA ? 5 : 4), 48));
Winson Chung5f8afe62013-08-12 16:19:28 -0700495 deviceProfiles.add(new DeviceProfile("Nexus 4",
Winson Chungc58497e2013-09-03 17:48:37 -0700496 359, 518, 4, 4, 60, 12, (hasAA ? 5 : 4), 56));
Winson Chung5f8afe62013-08-12 16:19:28 -0700497 // The tablet profile is odd in that the landscape orientation
498 // also includes the nav bar on the side
499 deviceProfiles.add(new DeviceProfile("Nexus 7",
500 575, 904, 6, 6, 72, 14.4f, 7, 60));
501 // Larger tablet profiles always have system bars on the top & bottom
502 deviceProfiles.add(new DeviceProfile("Nexus 10",
503 727, 1207, 5, 8, 80, 14.4f, 9, 64));
504 /*
505 deviceProfiles.add(new DeviceProfile("Nexus 7",
506 600, 960, 5, 5, 72, 14.4f, 5, 60));
507 deviceProfiles.add(new DeviceProfile("Nexus 10",
Winson Chungc58497e2013-09-03 17:48:37 -0700508 800, 1280, 5, 5, 80, 14.4f, (hasAA ? 7 : 6), 64));
Winson Chung5f8afe62013-08-12 16:19:28 -0700509 */
510 deviceProfiles.add(new DeviceProfile("20-inch Tablet",
511 1527, 2527, 7, 7, 100, 20, 7, 72));
512 mMinWidth = dpiFromPx(minWidthPx, dm);
513 mMinHeight = dpiFromPx(minHeightPx, dm);
514 mProfile = new DeviceProfile(deviceProfiles,
Winson Chung892c74d2013-08-22 16:15:50 -0700515 mMinWidth, mMinHeight,
Winson Chung5f8afe62013-08-12 16:19:28 -0700516 widthPx, heightPx,
Winson Chung892c74d2013-08-22 16:15:50 -0700517 awPx, ahPx,
Winson Chung5f8afe62013-08-12 16:19:28 -0700518 resources);
519 }
520
521 DeviceProfile getDeviceProfile() {
522 return mProfile;
523 }
524
525 public String toString() {
526 return "-------- DYNAMIC GRID ------- \n" +
527 "Wd: " + mProfile.minWidthDps + ", Hd: " + mProfile.minHeightDps +
528 ", W: " + mProfile.widthPx + ", H: " + mProfile.heightPx +
529 " [r: " + mProfile.numRows + ", c: " + mProfile.numColumns +
530 ", is: " + mProfile.iconSizePx + ", its: " + mProfile.iconTextSize +
531 ", cw: " + mProfile.cellWidthPx + ", ch: " + mProfile.cellHeightPx +
532 ", hc: " + mProfile.numHotseatIcons + ", his: " + mProfile.hotseatIconSizePx + "]";
533 }
534}