From 657b03a6fc40a0ea9b867861e208bcfc5854af3e Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Thu, 1 Oct 2020 15:11:28 +0200 Subject: Android: small change to access to device diagonal value --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'android-project') 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 0c4ec139a..05b83db3d 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 @@ -1031,14 +1031,12 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh return false; } - /** - * This method is called by SDL using JNI. - */ - public static boolean isTablet() { + public static double getDiagonal() + { DisplayMetrics metrics = new DisplayMetrics(); Activity activity = (Activity)getContext(); if (activity == null) { - return false; + return 0.0; } activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); @@ -1047,8 +1045,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh double dDiagonal = Math.sqrt((dWidthInches * dWidthInches) + (dHeightInches * dHeightInches)); + return dDiagonal; + } + + /** + * This method is called by SDL using JNI. + */ + public static boolean isTablet() { // If our diagonal size is seven inches or greater, we consider ourselves a tablet. - return (dDiagonal >= 7.0); + return (getDiagonal() >= 7.0); } /** -- cgit v1.2.1