private static final String OS_WINDOWS = "win";
private static final String OS_LINUX = "lin";
private static final String OS_MACOSX = "mac";
-
- private static final String MOS_ANDROID = "android";
- private static final String MOS_IOS = "ios";
+ private static final String OS_ANDROID = "android";
+ private static final String OS_IOS = "ios";
private static BrowserInfo instance;
cssClass = cssClass + " " + prefix + osClass;
}
- String mosClass = getMobileOperatingSystemClass();
- if (mosClass != null) {
- cssClass = cssClass + " " + prefix + mosClass;
- }
}
return cssClass;
}
private String getOperatingSystemClass() {
- if (browserDetails.isWindows()) {
+ if (browserDetails.isAndroid()) {
+ return OS_ANDROID;
+ } else if (browserDetails.isIOS()) {
+ return OS_IOS;
+ } else if (browserDetails.isWindows()) {
return OS_WINDOWS;
} else if (browserDetails.isLinux()) {
return OS_LINUX;
return null;
}
- private String getMobileOperatingSystemClass() {
- if (isAndroid()) {
- return MOS_ANDROID;
- } else if (browserDetails.isIOS()) {
- return MOS_IOS;
- }
- // Unknown MOS
- return null;
- }
-
public boolean isIE() {
return browserDetails.isIE();
}
private boolean isIE = false;
private OperatingSystem os = OperatingSystem.UNKNOWN;
- private MobileSystem ms = MobileSystem.UNKNOWN;
public enum OperatingSystem {
- UNKNOWN, WINDOWS, MACOSX, LINUX;
- }
-
- public enum MobileSystem {
- UNKNOWN, IOS, ANDROID;
+ UNKNOWN, WINDOWS, MACOSX, LINUX, IOS, ANDROID;
}
private float browserEngineVersion = -1;
if (userAgent.contains("windows ")) {
os = OperatingSystem.WINDOWS;
} else if (userAgent.contains("linux")) {
- os = OperatingSystem.LINUX;
if (userAgent.contains("android")) {
- ms = MobileSystem.ANDROID;
+ os = OperatingSystem.ANDROID;
+ } else {
+ os = OperatingSystem.LINUX;
}
} else if (userAgent.contains("macintosh")
|| userAgent.contains("mac osx")
|| userAgent.contains("mac os x")) {
- os = OperatingSystem.MACOSX;
if (userAgent.contains("ipad") || userAgent.contains("ipod")
|| userAgent.contains("iphone")) {
- ms = MobileSystem.IOS;
+ os = OperatingSystem.IOS;
+ } else {
+ os = OperatingSystem.MACOSX;
}
}
}
* @return true if run on Android, false otherwise
*/
public boolean isAndroid() {
- return ms == MobileSystem.ANDROID;
+ return os == OperatingSystem.ANDROID;
}
/**
* @return true if run in iOS, false otherwise
*/
public boolean isIOS() {
- return ms == MobileSystem.IOS;
+ return os == OperatingSystem.IOS;
}
}