Android: small change to access to device diagonal value

Sylvain Becker 2020-10-01 15:11:28 +02:00
parent 62b029f33b
commit 0467e332af
1 changed files with 11 additions and 6 deletions

View File

@ -1031,14 +1031,12 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return false; return false;
} }
/** public static double getDiagonal()
* This method is called by SDL using JNI. {
*/
public static boolean isTablet() {
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
Activity activity = (Activity)getContext(); Activity activity = (Activity)getContext();
if (activity == null) { if (activity == null) {
return false; return 0.0;
} }
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); 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)); 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. // If our diagonal size is seven inches or greater, we consider ourselves a tablet.
return (dDiagonal >= 7.0); return (getDiagonal() >= 7.0);
} }
/** /**