• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.ui.base;
6 
7 import android.content.Context;
8 
9 import org.chromium.base.CalledByNative;
10 
11 /**
12  * UI utilities for accessing form factor information.
13  */
14 public class DeviceFormFactor {
15 
16     /**
17      * The minimum width that would classify the device as a tablet.
18      */
19     private static final int MINIMUM_TABLET_WIDTH_DP = 600;
20 
21     private static Boolean sIsTablet = null;
22 
23     /**
24      * @param context Android's context
25      * @return        Whether the app is should treat the device as a tablet for layout.
26      */
27     @CalledByNative
isTablet(Context context)28     public static boolean isTablet(Context context) {
29         if (sIsTablet == null) {
30             int minimumScreenWidthDp = context.getResources().getConfiguration().
31                     smallestScreenWidthDp;
32             sIsTablet = minimumScreenWidthDp >= MINIMUM_TABLET_WIDTH_DP;
33         }
34         return sIsTablet;
35     }
36 }
37