Fixed tablet detection on Android
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Sep 2018 02:14:46 -0700
changeset 12260b367ab442dc6
parent 12259 c63a539aae19
child 12265 dfa5cea01a56
Fixed tablet detection on Android
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sat Sep 29 09:20:50 2018 +0300
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sat Sep 29 02:14:46 2018 -0700
     1.3 @@ -843,16 +843,16 @@
     1.4       */
     1.5      public static boolean isTablet() {
     1.6          DisplayMetrics metrics = new DisplayMetrics();
     1.7 -        Activity sdlActivity = (Activity)getContext();
     1.8 -        sdlActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
     1.9 +        Activity activity = (Activity)getContext();
    1.10 +        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    1.11  
    1.12 -        double dWidthInches = metrics.widthPixels / (double)metrics.densityDpi;
    1.13 -        double dHeightInches = metrics.heightPixels / (double)metrics.densityDpi;
    1.14 +        double dWidthInches = metrics.widthPixels / (double)metrics.xdpi;
    1.15 +        double dHeightInches = metrics.heightPixels / (double)metrics.ydpi;
    1.16  
    1.17          double dDiagonal = Math.sqrt((dWidthInches * dWidthInches) + (dHeightInches * dHeightInches));
    1.18  
    1.19          // If our diagonal size is seven inches or greater, we consider ourselves a tablet.
    1.20 -        return (dDiagonal > 7.0);
    1.21 +        return (dDiagonal >= 7.0);
    1.22      }
    1.23  
    1.24      /**