mirror of https://github.com/libsdl-org/SDL
Fixed tablet detection on Android
This commit is contained in:
parent
35422bd893
commit
e77ec88969
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue