From e77ec8896974a37c172f765fffeef1ecdb85c2b0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 29 Sep 2018 02:14:46 -0700 Subject: [PATCH] Fixed tablet detection on Android --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 071b343b4..360176253 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -843,16 +843,16 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh */ 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); } /**