[Commits] SDL: Fixed tablet detection on Android

libsdl.org revision control commits-owner at libsdl.org
Sat Sep 29 02:14:49 PDT 2018


details:   https://hg.libsdl.org/SDL/rev/b367ab442dc6
changeset: 12260:b367ab442dc6
user:      Sam Lantinga <slouken at libsdl.org>
date:      Sat Sep 29 02:14:46 2018 -0700
description:
Fixed tablet detection on Android

diffstat:

 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (25 lines):

diff -r c63a539aae19 -r b367ab442dc6 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sat Sep 29 09:20:50 2018 +0300
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Sat Sep 29 02:14:46 2018 -0700
@@ -843,16 +843,16 @@
      */
     public static boolean isTablet() {
         DisplayMetrics metrics = new DisplayMetrics();
-        Activity sdlActivity = (Activity)getContext();
-        sdlActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
+        Activity activity = (Activity)getContext();
+        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
 
-        double dWidthInches = metrics.widthPixels / (double)metrics.densityDpi;
-        double dHeightInches = metrics.heightPixels / (double)metrics.densityDpi;
+        double dWidthInches = metrics.widthPixels / (double)metrics.xdpi;
+        double dHeightInches = metrics.heightPixels / (double)metrics.ydpi;
 
         double dDiagonal = Math.sqrt((dWidthInches * dWidthInches) + (dHeightInches * dHeightInches));
 
         // If our diagonal size is seven inches or greater, we consider ourselves a tablet.
-        return (dDiagonal > 7.0);
+        return (dDiagonal >= 7.0);
     }
 
     /**


More information about the commits mailing list