mirror of https://github.com/encounter/SDL.git
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() {
|
public static boolean isTablet() {
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
Activity sdlActivity = (Activity)getContext();
|
Activity activity = (Activity)getContext();
|
||||||
sdlActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
|
|
||||||
double dWidthInches = metrics.widthPixels / (double)metrics.densityDpi;
|
double dWidthInches = metrics.widthPixels / (double)metrics.xdpi;
|
||||||
double dHeightInches = metrics.heightPixels / (double)metrics.densityDpi;
|
double dHeightInches = metrics.heightPixels / (double)metrics.ydpi;
|
||||||
|
|
||||||
double dDiagonal = Math.sqrt((dWidthInches * dWidthInches) + (dHeightInches * dHeightInches));
|
double dDiagonal = Math.sqrt((dWidthInches * dWidthInches) + (dHeightInches * dHeightInches));
|
||||||
|
|
||||||
// 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 (dDiagonal >= 7.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue