Fixed tablet detection on Android

This commit is contained in:
Sam Lantinga 2018-09-29 02:14:46 -07:00
parent 35422bd893
commit e77ec88969
1 changed files with 5 additions and 5 deletions

View File

@ -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);
}
/**