Subversion Repository Public Repository

litesoft

Diff Revisions 948 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/UserAgent.java

Diff revisions: vs.
  @@ -1,81 +1,81 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client;
3 -
4 - import org.litesoft.core.*;
5 -
6 - import com.google.gwt.core.client.*;
7 -
8 - public class UserAgent {
9 - private static UserAgent sInstance = null;
10 -
11 - public static UserAgent getInstance() {
12 - if ( sInstance == null ) {
13 - sInstance = (UserAgent) GWT.create( UserAgent.class );
14 - }
15 - return sInstance;
16 - }
17 -
18 - private final DeviceType mDeviceType;
19 - private final Platform mPlatform;
20 - private final BrowserFamily mFamily;
21 - private final String mReally;
22 - private final Integer mVersion;
23 -
24 - protected UserAgent( BrowserFamily pFamily, String pReally, Integer pVersion ) {
25 - String zLowercaseUserAgent = getBrowserUserAgent().toLowerCase();
26 - mDeviceType = DeviceType.fromUserAgent( zLowercaseUserAgent );
27 - mPlatform = Platform.fromUserAgent( mDeviceType, zLowercaseUserAgent );
28 - mFamily = pFamily;
29 - mReally = (pVersion == null) ? pReally : pReally + pVersion;
30 - mVersion = pVersion;
31 - }
32 -
33 - protected UserAgent( BrowserFamily pFamily, String pReally ) {
34 - this( pFamily, pReally, null );
35 - }
36 -
37 - protected UserAgent( BrowserFamily pFamily ) {
38 - this( pFamily, "" );
39 - }
40 -
41 - protected UserAgent() {
42 - this( BrowserFamily.Other );
43 - }
44 -
45 - public DeviceType getDeviceType() {
46 - return mDeviceType;
47 - }
48 -
49 - public Platform getPlatform() {
50 - return mPlatform;
51 - }
52 -
53 - public BrowserFamily getFamily() {
54 - return mFamily;
55 - }
56 -
57 - public String getReally() {
58 - return mReally;
59 - }
60 -
61 - public Integer getVersion() {
62 - return mVersion;
63 - }
64 -
65 - public boolean isLegacyIE() {
66 - return false;
67 - }
68 -
69 - public static native String getBrowserUserAgent() /*-{
70 - return navigator.userAgent;
71 - }-*/;
72 -
73 - @Override
74 - public String toString() {
75 - StringBuilder sb = new StringBuilder();
76 - sb.append( mDeviceType ).append( '-' ).append( mPlatform );
77 - sb.append( '-' ).append( mFamily ).append( '-' ).append( mReally );
78 - sb.append( " '" ).append( getBrowserUserAgent() ).append( "'" );
79 - return sb.toString();
80 - }
81 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client;
3 +
4 + import org.litesoft.core.*;
5 +
6 + import com.google.gwt.core.client.*;
7 +
8 + public class UserAgent {
9 + private static UserAgent sInstance = null;
10 +
11 + public static UserAgent getInstance() {
12 + if ( sInstance == null ) {
13 + sInstance = (UserAgent) GWT.create( UserAgent.class );
14 + }
15 + return sInstance;
16 + }
17 +
18 + private final DeviceType mDeviceType;
19 + private final Platform mPlatform;
20 + private final BrowserFamily mFamily;
21 + private final String mReally;
22 + private final Integer mVersion;
23 +
24 + protected UserAgent( BrowserFamily pFamily, String pReally, Integer pVersion ) {
25 + String zLowercaseUserAgent = getBrowserUserAgent().toLowerCase();
26 + mDeviceType = DeviceType.fromUserAgent( zLowercaseUserAgent );
27 + mPlatform = Platform.fromUserAgent( mDeviceType, zLowercaseUserAgent );
28 + mFamily = pFamily;
29 + mReally = (pVersion == null) ? pReally : pReally + pVersion;
30 + mVersion = pVersion;
31 + }
32 +
33 + protected UserAgent( BrowserFamily pFamily, String pReally ) {
34 + this( pFamily, pReally, null );
35 + }
36 +
37 + protected UserAgent( BrowserFamily pFamily ) {
38 + this( pFamily, "" );
39 + }
40 +
41 + protected UserAgent() {
42 + this( BrowserFamily.Other );
43 + }
44 +
45 + public DeviceType getDeviceType() {
46 + return mDeviceType;
47 + }
48 +
49 + public Platform getPlatform() {
50 + return mPlatform;
51 + }
52 +
53 + public BrowserFamily getFamily() {
54 + return mFamily;
55 + }
56 +
57 + public String getReally() {
58 + return mReally;
59 + }
60 +
61 + public Integer getVersion() {
62 + return mVersion;
63 + }
64 +
65 + public boolean isLegacyIE() {
66 + return false;
67 + }
68 +
69 + public static native String getBrowserUserAgent() /*-{
70 + return navigator.userAgent;
71 + }-*/;
72 +
73 + @Override
74 + public String toString() {
75 + StringBuilder sb = new StringBuilder();
76 + sb.append( mDeviceType ).append( '-' ).append( mPlatform );
77 + sb.append( '-' ).append( mFamily ).append( '-' ).append( mReally );
78 + sb.append( " '" ).append( getBrowserUserAgent() ).append( "'" );
79 + return sb.toString();
80 + }
81 + }