mobileesp_converted 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,35 +1,26 @@
1
1
  /* *******************************************
2
- // Copyright 2010-2012, Anthony Hand
2
+ // Copyright 2010-2013, Anthony Hand
3
3
  //
4
- // File version date: April 23, 2012
5
- // Update:
6
- // - Updated DetectAmazonSilk(): Fixed an issue in the detection logic.
4
+ // File version 2013.08.01 (August 1, 2013)
5
+ // Updates:
6
+ // - Updated DetectMobileQuick(). Moved the 'Exclude Tablets' logic to the top of the method to fix a logic bug.
7
7
  //
8
- // File version date: April 22, 2012 - Second update
9
- // Update: To address additional Kindle issues...
10
- // - Updated DetectRichCSS(): Excluded e-Ink Kindle devices.
11
- // - Created DetectAmazonSilk(): Created to detect Kindle Fire devices in Silk mode.
12
- // - Updated DetectMobileQuick(): Updated to include e-Ink Kindle devices and the Kindle Fire in Silk mode.
8
+ // File version 2013.07.13 (July 13, 2013)
9
+ // Updates:
10
+ // - Added support for Tizen: variable and DetectTizen().
11
+ // - Added support for Meego: variable and DetectMeego().
12
+ // - Added support for Windows Phone 8: variable and DetectWindowsPhone8().
13
+ // - Added a generic Windows Phone method: DetectWindowsPhone().
14
+ // - Added support for BlackBerry 10 OS: variable and DetectBlackBerry10Phone().
15
+ // - Added support for PlayStation Vita handheld: variable and DetectGamingHandheld().
16
+ // - Updated DetectTierIphone(). Added Tizen; updated the Windows Phone, BB10, and PS Vita support.
17
+ // - Updated DetectWindowsMobile(). Uses generic DetectWindowsPhone() method rather than WP7.
18
+ // - Updated DetectSmartphone(). Uses the detectTierIphone() method.
19
+ // - Updated DetectSonyMylo() with more efficient code.
20
+ // - Removed DetectGarminNuvifone() from DetectTierIphone(). How many are left in market in 2013? It is detected as a RichCSS Tier device.
21
+ // - Removed the deviceXoom variable. It was unused.
22
+ // - Added detection support for the Obigo mobile browser to DetectMobileQuick().
13
23
  //
14
- // File version date: April 11, 2012
15
- // Update:
16
- // - Added a new variable for the new BlackBerry Curve Touch (9380): deviceBBCurveTouch.
17
- // - Updated DetectBlackBerryTouch() to support the new BlackBerry Curve Touch (9380).
18
- //
19
- // File version date: January 21, 2012
20
- // Update:
21
- // - Moved Windows Phone 7 to the iPhone Tier. WP7.5's IE 9-based browser is good enough now.
22
- // - Added a new variable for 2 versions of the new BlackBerry Bold Touch (9900 and 9930): deviceBBBoldTouch.
23
- // - Updated DetectBlackBerryTouch() to support the 2 versions of the new BlackBerry Bold Touch (9900 and 9930).
24
- // - Updated DetectKindle() to focus on eInk devices only. The Kindle Fire should be detected as a regular Android device.
25
- //
26
- // File version date: August 22, 2011
27
- // Update:
28
- // - Updated DetectAndroidTablet() to fix a bug I introduced in the last fix!
29
- //
30
- // File version date: August 16, 2011
31
- // Update:
32
- // - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone.
33
24
  //
34
25
  //
35
26
  // LICENSE INFORMATION
@@ -74,12 +65,16 @@ public class UAgentInfo {
74
65
  private String httpAccept = "";
75
66
 
76
67
  // Let's store values for quickly accessing the same info multiple times.
77
- public boolean isIphone = false;
78
- public boolean isAndroidPhone = false;
79
- public boolean isTierTablet = false;
80
- public boolean isTierIphone = false;
81
- public boolean isTierRichCss = false;
82
- public boolean isTierGenericMobile = false;
68
+ public boolean initCompleted = false;
69
+ public boolean isWebkit = false; //Stores the result of DetectWebkit()
70
+ public boolean isMobilePhone = false; //Stores the result of DetectMobileQuick()
71
+ public boolean isIphone = false; //Stores the result of DetectIphone()
72
+ public boolean isAndroid = false; //Stores the result of DetectAndroid()
73
+ public boolean isAndroidPhone = false; //Stores the result of DetectAndroidPhone()
74
+ public boolean isTierTablet = false; //Stores the result of DetectTierTablet()
75
+ public boolean isTierIphone = false; //Stores the result of DetectTierIphone()
76
+ public boolean isTierRichCss = false; //Stores the result of DetectTierRichCss()
77
+ public boolean isTierGenericMobile = false; //Stores the result of DetectTierOtherPhones()
83
78
 
84
79
  // Initialize some initial smartphone string variables.
85
80
  public static final String engineWebKit = "webkit";
@@ -91,16 +86,10 @@ public class UAgentInfo {
91
86
 
92
87
  public static final String deviceAndroid = "android";
93
88
  public static final String deviceGoogleTV = "googletv";
94
- public static final String deviceXoom = "xoom"; //Motorola Xoom
95
89
  public static final String deviceHtcFlyer = "htc_flyer"; //HTC Flyer
96
90
 
97
- public static final String deviceSymbian = "symbian";
98
- public static final String deviceS60 = "series60";
99
- public static final String deviceS70 = "series70";
100
- public static final String deviceS80 = "series80";
101
- public static final String deviceS90 = "series90";
102
-
103
91
  public static final String deviceWinPhone7 = "windows phone os 7";
92
+ public static final String deviceWinPhone8 = "windows phone 8";
104
93
  public static final String deviceWinMob = "windows ce";
105
94
  public static final String deviceWindows = "windows";
106
95
  public static final String deviceIeMob = "iemobile";
@@ -108,6 +97,7 @@ public class UAgentInfo {
108
97
  public static final String enginePie = "wm5 pie"; //An old Windows Mobile
109
98
 
110
99
  public static final String deviceBB = "blackberry";
100
+ public static final String deviceBB10 = "bb10"; //For the new BB 10 OS
111
101
  public static final String vndRIM = "vnd.rim"; //Detectable when BB devices emulate IE or Firefox
112
102
  public static final String deviceBBStorm = "blackberry95"; //Storm 1 and 2
113
103
  public static final String deviceBBBold = "blackberry97"; //Bold 97x0 (non-touch)
@@ -118,17 +108,25 @@ public class UAgentInfo {
118
108
  public static final String deviceBBTorch = "blackberry 98"; //Torch
119
109
  public static final String deviceBBPlaybook = "playbook"; //PlayBook tablet
120
110
 
111
+ public static final String deviceSymbian = "symbian";
112
+ public static final String deviceS60 = "series60";
113
+ public static final String deviceS70 = "series70";
114
+ public static final String deviceS80 = "series80";
115
+ public static final String deviceS90 = "series90";
116
+
121
117
  public static final String devicePalm = "palm";
122
118
  public static final String deviceWebOS = "webos"; //For Palm's line of WebOS devices
123
119
  public static final String deviceWebOShp = "hpwos"; //For HP's line of WebOS devices
124
-
125
120
  public static final String engineBlazer = "blazer"; //Old Palm
126
121
  public static final String engineXiino = "xiino"; //Another old Palm
127
122
 
128
- public static final String deviceKindle = "kindle"; //Amazon Kindle, eInk one
129
- public static final String engineSilk = "silk"; //Amazon's accelerated Silk browser for Kindle Fire
130
-
131
123
  public static final String deviceNuvifone = "nuvifone"; //Garmin Nuvifone
124
+ public static final String deviceBada = "bada"; //Samsung's Bada OS
125
+ public static final String deviceTizen = "tizen"; //Tizen OS
126
+ public static final String deviceMeego = "meego"; //Meego OS
127
+
128
+ public static final String deviceKindle = "kindle"; //Amazon Kindle, eInk one
129
+ public static final String engineSilk = "silk-accelerated"; //Amazon's accelerated Silk browser for Kindle Fire
132
130
 
133
131
  //Initialize variables for mobile-specific content.
134
132
  public static final String vndwap = "vnd.wap";
@@ -140,6 +138,7 @@ public class UAgentInfo {
140
138
  public static final String deviceDanger = "danger";
141
139
  public static final String deviceHiptop = "hiptop";
142
140
  public static final String devicePlaystation = "playstation";
141
+ public static final String devicePlaystationVita = "vita";
143
142
  public static final String deviceNintendoDs = "nitro";
144
143
  public static final String deviceNintendo = "nintendo";
145
144
  public static final String deviceWii = "wii";
@@ -153,6 +152,8 @@ public class UAgentInfo {
153
152
  public static final String deviceMidp = "midp"; //a mobile Java technology
154
153
  public static final String uplink = "up.link";
155
154
  public static final String engineTelecaQ = "teleca q"; //a modern feature phone browser
155
+ public static final String engineObigo = "obigo"; //W 10 is a modern feature phone browser
156
+
156
157
  public static final String devicePda = "pda"; //some devices report themselves as PDAs
157
158
  public static final String mini = "mini"; //Some mobile browsers put "mini" in their names.
158
159
  public static final String mobile = "mobile"; //Some mobile browsers put "mobile" in their user agent strings.
@@ -169,7 +170,7 @@ public class UAgentInfo {
169
170
  public static final String manuericsson = "ericsson";
170
171
  public static final String manuSamsung1 = "sec-sgh";
171
172
  public static final String manuSony = "sony";
172
- public static final String manuHtc = "htc"; //Popular Android and WinMo manufacturer
173
+ public static final String manuHtc = "htc";
173
174
 
174
175
  //In some UserAgents, the only clue is the operator.
175
176
  public static final String svcDocomo = "docomo";
@@ -258,12 +259,22 @@ public class UAgentInfo {
258
259
  * Initialize Key Stored Values.
259
260
  */
260
261
  public void initDeviceScan() {
261
- this.isIphone = detectIphoneOrIpod();
262
+ //Save these properties to speed processing
263
+ this.isWebkit = detectWebkit();
264
+ this.isIphone = detectIphone();
265
+ this.isAndroid = detectAndroid();
262
266
  this.isAndroidPhone = detectAndroidPhone();
267
+
268
+ //Generally, these tiers are the most useful for web development
269
+ this.isMobilePhone = detectMobileQuick();
263
270
  this.isTierTablet = detectTierTablet();
264
271
  this.isTierIphone = detectTierIphone();
272
+
273
+ //Optional: Comment these out if you NEVER use them
265
274
  this.isTierRichCss = detectTierRichCss();
266
275
  this.isTierGenericMobile = detectTierOtherPhones();
276
+
277
+ this.initCompleted = true;
267
278
  }
268
279
 
269
280
  /**
@@ -271,6 +282,10 @@ public class UAgentInfo {
271
282
  * @return detection of an iPhone
272
283
  */
273
284
  public boolean detectIphone() {
285
+ if ((this.initCompleted == true) ||
286
+ (this.isIphone == true))
287
+ return this.isIphone;
288
+
274
289
  // The iPad and iPod touch say they're an iPhone! So let's disambiguate.
275
290
  if (userAgent.indexOf(deviceIphone) != -1 &&
276
291
  !detectIpad() &&
@@ -334,6 +349,10 @@ public class UAgentInfo {
334
349
  * @return detection of an Android device
335
350
  */
336
351
  public boolean detectAndroid() {
352
+ if ((this.initCompleted == true) ||
353
+ (this.isAndroid == true))
354
+ return this.isAndroid;
355
+
337
356
  if ((userAgent.indexOf(deviceAndroid) != -1) ||
338
357
  detectGoogleTV())
339
358
  return true;
@@ -351,6 +370,10 @@ public class UAgentInfo {
351
370
  * @return detection of an Android phone
352
371
  */
353
372
  public boolean detectAndroidPhone() {
373
+ if ((this.initCompleted == true) ||
374
+ (this.isAndroidPhone == true))
375
+ return this.isAndroidPhone;
376
+
354
377
  if (detectAndroid() && (userAgent.indexOf(mobile) != -1))
355
378
  return true;
356
379
  //Special check for Android phones with Opera Mobile. They should report here.
@@ -414,51 +437,45 @@ public class UAgentInfo {
414
437
  * @return detection of a WebKit browser
415
438
  */
416
439
  public boolean detectWebkit() {
440
+ if ((this.initCompleted == true) ||
441
+ (this.isWebkit == true))
442
+ return this.isWebkit;
443
+
417
444
  if (userAgent.indexOf(engineWebKit) != -1) {
418
445
  return true;
419
446
  }
420
447
  return false;
421
448
  }
422
449
 
450
+
423
451
  /**
424
- * Detects if the current browser is the Symbian S60 Open Source Browser.
425
- * @return detection of Symbian S60 Browser
452
+ * Detects if the current browser is EITHER a Windows Phone 7.x OR 8 device
453
+ * @return detection of Windows Phone 7.x OR 8
426
454
  */
427
- public boolean detectS60OssBrowser() {
428
- //First, test for WebKit, then make sure it's either Symbian or S60.
429
- if (detectWebkit()
430
- && (userAgent.indexOf(deviceSymbian) != -1
431
- || userAgent.indexOf(deviceS60) != -1)) {
455
+ public boolean detectWindowsPhone() {
456
+ if (detectWindowsPhone7() || detectWindowsPhone8()) {
432
457
  return true;
433
458
  }
434
459
  return false;
435
460
  }
436
461
 
437
462
  /**
438
- *
439
- * Detects if the current device is any Symbian OS-based device,
440
- * including older S60, Series 70, Series 80, Series 90, and UIQ,
441
- * or other browsers running on these devices.
442
- * @return detection of SymbianOS
463
+ * Detects a Windows Phone 7.x device (in mobile browsing mode).
464
+ * @return detection of Windows Phone 7
443
465
  */
444
- public boolean detectSymbianOS() {
445
- if (userAgent.indexOf(deviceSymbian) != -1
446
- || userAgent.indexOf(deviceS60) != -1
447
- || userAgent.indexOf(deviceS70) != -1
448
- || userAgent.indexOf(deviceS80) != -1
449
- || userAgent.indexOf(deviceS90) != -1) {
466
+ public boolean detectWindowsPhone7() {
467
+ if (userAgent.indexOf(deviceWinPhone7) != -1) {
450
468
  return true;
451
469
  }
452
470
  return false;
453
471
  }
454
-
472
+
455
473
  /**
456
- * Detects if the current browser is a
457
- * Windows Phone 7 device.
458
- * @return detection of Windows Phone 7
474
+ * Detects a Windows Phone 8 device (in mobile browsing mode).
475
+ * @return detection of Windows Phone 8
459
476
  */
460
- public boolean detectWindowsPhone7() {
461
- if (userAgent.indexOf(deviceWinPhone7) != -1) {
477
+ public boolean detectWindowsPhone8() {
478
+ if (userAgent.indexOf(deviceWinPhone8) != -1) {
462
479
  return true;
463
480
  }
464
481
  return false;
@@ -466,13 +483,12 @@ public class UAgentInfo {
466
483
 
467
484
  /**
468
485
  * Detects if the current browser is a Windows Mobile device.
469
- * Excludes Windows Phone 7 devices.
486
+ * Excludes Windows Phone 7.x and 8 devices.
470
487
  * Focuses on Windows Mobile 6.xx and earlier.
471
488
  * @return detection of Windows Mobile
472
489
  */
473
490
  public boolean detectWindowsMobile() {
474
- //Exclude new Windows Phone 7.
475
- if (detectWindowsPhone7()) {
491
+ if (detectWindowsPhone()) {
476
492
  return false;
477
493
  }
478
494
  //Most devices use 'Windows CE', but some report 'iemobile'
@@ -495,14 +511,31 @@ public class UAgentInfo {
495
511
  return false;
496
512
  }
497
513
 
514
+
498
515
  /**
499
516
  * Detects if the current browser is any BlackBerry.
500
- * Includes the PlayBook.
517
+ * Includes BB10 OS, but excludes the PlayBook.
501
518
  * @return detection of Blackberry
502
519
  */
503
520
  public boolean detectBlackBerry() {
504
521
  if (userAgent.indexOf(deviceBB) != -1 ||
505
- httpAccept.indexOf(vndRIM) != -1) {
522
+ httpAccept.indexOf(vndRIM) != -1)
523
+ return true;
524
+
525
+ if (detectBlackBerry10Phone())
526
+ return true;
527
+
528
+ return false;
529
+ }
530
+
531
+ /**
532
+ * Detects if the current browser is a BlackBerry 10 OS phone.
533
+ * Excludes tablets.
534
+ * @return detection of a Blackberry 10 device
535
+ */
536
+ public boolean detectBlackBerry10Phone() {
537
+ if (userAgent.indexOf(deviceBB10) != -1 &&
538
+ userAgent.indexOf(mobile) != -1) {
506
539
  return true;
507
540
  }
508
541
  return false;
@@ -527,10 +560,8 @@ public class UAgentInfo {
527
560
  * @return detection of a Blackberry device with WebKit browser
528
561
  */
529
562
  public boolean detectBlackBerryWebKit() {
530
- if (detectBlackBerry() &&
531
- userAgent.indexOf(engineWebKit) != -1) {
563
+ if (detectBlackBerry() && detectWebkit())
532
564
  return true;
533
- }
534
565
  return false;
535
566
  }
536
567
 
@@ -544,8 +575,8 @@ public class UAgentInfo {
544
575
  (userAgent.indexOf(deviceBBStorm) != -1 ||
545
576
  userAgent.indexOf(deviceBBTorch) != -1 ||
546
577
  userAgent.indexOf(deviceBBBoldTouch) != -1 ||
547
- userAgent.indexOf(deviceBBCurveTouch) != -1 )) {
548
- return true;
578
+ userAgent.indexOf(deviceBBCurveTouch) != -1 )) {
579
+ return true;
549
580
  }
550
581
  return false;
551
582
  }
@@ -595,21 +626,54 @@ public class UAgentInfo {
595
626
  }
596
627
  }
597
628
 
629
+
630
+ /**
631
+ * Detects if the current browser is the Symbian S60 Open Source Browser.
632
+ * @return detection of Symbian S60 Browser
633
+ */
634
+ public boolean detectS60OssBrowser() {
635
+ //First, test for WebKit, then make sure it's either Symbian or S60.
636
+ if (detectWebkit()
637
+ && (userAgent.indexOf(deviceSymbian) != -1
638
+ || userAgent.indexOf(deviceS60) != -1)) {
639
+ return true;
640
+ }
641
+ return false;
642
+ }
643
+
644
+ /**
645
+ *
646
+ * Detects if the current device is any Symbian OS-based device,
647
+ * including older S60, Series 70, Series 80, Series 90, and UIQ,
648
+ * or other browsers running on these devices.
649
+ * @return detection of SymbianOS
650
+ */
651
+ public boolean detectSymbianOS() {
652
+ if (userAgent.indexOf(deviceSymbian) != -1
653
+ || userAgent.indexOf(deviceS60) != -1
654
+ || userAgent.indexOf(deviceS70) != -1
655
+ || userAgent.indexOf(deviceS80) != -1
656
+ || userAgent.indexOf(deviceS90) != -1) {
657
+ return true;
658
+ }
659
+ return false;
660
+ }
661
+
662
+
598
663
  /**
599
664
  * Detects if the current browser is on a PalmOS device.
600
665
  * @return detection of a PalmOS device
601
666
  */
602
667
  public boolean detectPalmOS() {
668
+ //Make sure it's not WebOS first
669
+ if (detectPalmWebOS())
670
+ return false;
671
+
603
672
  //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
604
673
  if (userAgent.indexOf(devicePalm) != -1
605
674
  || userAgent.indexOf(engineBlazer) != -1
606
675
  || userAgent.indexOf(engineXiino) != -1) {
607
- //Make sure it's not WebOS first
608
- if (detectPalmWebOS()) {
609
- return false;
610
- } else {
611
676
  return true;
612
- }
613
677
  }
614
678
  return false;
615
679
  }
@@ -638,60 +702,6 @@ public class UAgentInfo {
638
702
  return false;
639
703
  }
640
704
 
641
- /**
642
- * Detects if the current browser is a
643
- * Garmin Nuvifone.
644
- * @return detection of a Garmin Nuvifone
645
- */
646
- public boolean detectGarminNuvifone() {
647
- if (userAgent.indexOf(deviceNuvifone) != -1) {
648
- return true;
649
- }
650
- return false;
651
- }
652
-
653
- /**
654
- * Check to see whether the device is any device
655
- * in the 'smartphone' category.
656
- * @return detection of a general smartphone device
657
- */
658
- public boolean detectSmartphone() {
659
- return (isIphone
660
- || isAndroidPhone
661
- || isTierIphone
662
- || detectS60OssBrowser()
663
- || detectSymbianOS()
664
- || detectWindowsMobile()
665
- || detectWindowsPhone7()
666
- || detectBlackBerry()
667
- || detectPalmWebOS()
668
- || detectPalmOS()
669
- || detectGarminNuvifone());
670
- }
671
-
672
- /**
673
- * Detects whether the device is a Brew-powered device.
674
- * @return detection of a Brew device
675
- */
676
- public boolean detectBrewDevice() {
677
- if (userAgent.indexOf(deviceBrew) != -1) {
678
- return true;
679
- }
680
- return false;
681
- }
682
-
683
- /**
684
- * Detects the Danger Hiptop device.
685
- * @return detection of a Danger Hiptop
686
- */
687
- public boolean detectDangerHiptop() {
688
- if (userAgent.indexOf(deviceDanger) != -1
689
- || userAgent.indexOf(deviceHiptop) != -1) {
690
- return true;
691
- }
692
- return false;
693
- }
694
-
695
705
  /**
696
706
  * Detects Opera Mobile or Opera Mini.
697
707
  * @return detection of an Opera browser for a mobile device
@@ -731,18 +741,6 @@ public class UAgentInfo {
731
741
  return false;
732
742
  }
733
743
 
734
- /**
735
- * Detects whether the device supports WAP or WML.
736
- * @return detection of a WAP- or WML-capable device
737
- */
738
- public boolean detectWapWml() {
739
- if (httpAccept.indexOf(vndwap) != -1
740
- || httpAccept.indexOf(wml) != -1) {
741
- return true;
742
- }
743
- return false;
744
- }
745
-
746
744
  /**
747
745
  * Detects if the current device is an Amazon Kindle (eInk devices only).
748
746
  * Note: For the Kindle Fire, use the normal Android methods.
@@ -769,55 +767,113 @@ public class UAgentInfo {
769
767
  }
770
768
 
771
769
  /**
772
- * Detects if the current device is a mobile device.
773
- * This method catches most of the popular modern devices.
774
- * Excludes Apple iPads and other modern tablets.
775
- * @return detection of any mobile device using the quicker method
770
+ * Detects if the current browser is a
771
+ * Garmin Nuvifone.
772
+ * @return detection of a Garmin Nuvifone
776
773
  */
777
- public boolean detectMobileQuick() {
778
- //Let's exclude tablets
779
- if (isTierTablet) {
780
- return false;
774
+ public boolean detectGarminNuvifone() {
775
+ if (userAgent.indexOf(deviceNuvifone) != -1) {
776
+ return true;
781
777
  }
782
- //Most mobile browsing is done on smartphones
783
- if (detectSmartphone()) {
778
+ return false;
779
+ }
780
+
781
+ /**
782
+ * Detects a device running the Bada smartphone OS from Samsung.
783
+ * @return detection of a Bada device
784
+ */
785
+ public boolean detectBada() {
786
+ if (userAgent.indexOf(deviceBada) != -1) {
784
787
  return true;
785
788
  }
789
+ return false;
790
+ }
786
791
 
787
- if (detectWapWml()
788
- || detectBrewDevice()
789
- || detectOperaMobile()) {
792
+ /**
793
+ * Detects a device running the Tizen smartphone OS.
794
+ * @return detection of a Tizen device
795
+ */
796
+ public boolean detectTizen() {
797
+ if (userAgent.indexOf(deviceTizen) != -1) {
790
798
  return true;
791
799
  }
800
+ return false;
801
+ }
792
802
 
793
- if ((userAgent.indexOf(engineNetfront) != -1)
794
- || (userAgent.indexOf(engineUpBrowser) != -1)
795
- || (userAgent.indexOf(engineOpenWeb) != -1)) {
803
+ /**
804
+ * Detects a device running the Meego OS.
805
+ * @return detection of a Meego device
806
+ */
807
+ public boolean detectMeego() {
808
+ if (userAgent.indexOf(deviceMeego) != -1) {
796
809
  return true;
797
810
  }
811
+ return false;
812
+ }
798
813
 
799
- if (detectDangerHiptop()
800
- || detectMidpCapable()
801
- || detectMaemoTablet()
802
- || detectArchos()) {
814
+ /**
815
+ * Detects the Danger Hiptop device.
816
+ * @return detection of a Danger Hiptop
817
+ */
818
+ public boolean detectDangerHiptop() {
819
+ if (userAgent.indexOf(deviceDanger) != -1
820
+ || userAgent.indexOf(deviceHiptop) != -1) {
803
821
  return true;
804
822
  }
823
+ return false;
824
+ }
805
825
 
806
- if ((userAgent.indexOf(devicePda) != -1) &&
807
- (userAgent.indexOf(disUpdate) < 0)) //no index found
808
- {
826
+ /**
827
+ * Detects if the current browser is a Sony Mylo device.
828
+ * @return detection of a Sony Mylo device
829
+ */
830
+ public boolean detectSonyMylo() {
831
+ if (userAgent.indexOf(manuSony) != -1
832
+ && (userAgent.indexOf(qtembedded) != -1
833
+ || userAgent.indexOf(mylocom2) != -1)) {
809
834
  return true;
810
835
  }
811
- if (userAgent.indexOf(mobile) != -1) {
836
+ return false;
837
+ }
838
+
839
+ /**
840
+ * Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
841
+ * @return detection of a Maemo OS tablet
842
+ */
843
+ public boolean detectMaemoTablet() {
844
+ if (userAgent.indexOf(maemo) != -1) {
845
+ return true;
846
+ } else if (userAgent.indexOf(linux) != -1
847
+ && userAgent.indexOf(deviceTablet) != -1
848
+ && !detectWebOSTablet()
849
+ && !detectAndroid()) {
812
850
  return true;
813
851
  }
852
+ return false;
853
+ }
814
854
 
815
- //We also look for Kindle devices
816
- if (detectKindle()
817
- || detectAmazonSilk()) {
855
+ /**
856
+ * Detects if the current device is an Archos media player/Internet tablet.
857
+ * @return detection of an Archos media player
858
+ */
859
+ public boolean detectArchos() {
860
+ if (userAgent.indexOf(deviceArchos) != -1) {
818
861
  return true;
819
862
  }
863
+ return false;
864
+ }
820
865
 
866
+ /**
867
+ * Detects if the current device is an Internet-capable game console.
868
+ * Includes many handheld consoles.
869
+ * @return detection of any Game Console
870
+ */
871
+ public boolean detectGameConsole() {
872
+ if (detectSonyPlaystation()
873
+ || detectNintendo()
874
+ || detectXbox()) {
875
+ return true;
876
+ }
821
877
  return false;
822
878
  }
823
879
 
@@ -832,6 +888,19 @@ public class UAgentInfo {
832
888
  return false;
833
889
  }
834
890
 
891
+ /**
892
+ * Detects if the current device is a handheld gaming device with
893
+ * a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
894
+ * @return detection of a handheld gaming device
895
+ */
896
+ public boolean detectGamingHandheld() {
897
+ if ((userAgent.indexOf(devicePlaystation) != -1) &&
898
+ (userAgent.indexOf(devicePlaystationVita) != -1)) {
899
+ return true;
900
+ }
901
+ return false;
902
+ }
903
+
835
904
  /**
836
905
  * Detects if the current device is a Nintendo game device.
837
906
  * @return detection of Nintendo
@@ -857,67 +926,109 @@ public class UAgentInfo {
857
926
  }
858
927
 
859
928
  /**
860
- * Detects if the current device is an Internet-capable game console.
861
- * @return detection of any Game Console
929
+ * Detects whether the device is a Brew-powered device.
930
+ * @return detection of a Brew device
862
931
  */
863
- public boolean detectGameConsole() {
864
- if (detectSonyPlaystation()
865
- || detectNintendo()
866
- || detectXbox()) {
932
+ public boolean detectBrewDevice() {
933
+ if (userAgent.indexOf(deviceBrew) != -1) {
867
934
  return true;
868
935
  }
869
936
  return false;
870
937
  }
871
938
 
872
939
  /**
873
- * Detects if the current device supports MIDP, a mobile Java technology.
874
- * @return detection of a MIDP mobile Java-capable device
940
+ * Detects whether the device supports WAP or WML.
941
+ * @return detection of a WAP- or WML-capable device
875
942
  */
876
- public boolean detectMidpCapable() {
877
- if (userAgent.indexOf(deviceMidp) != -1
878
- || httpAccept.indexOf(deviceMidp) != -1) {
943
+ public boolean detectWapWml() {
944
+ if (httpAccept.indexOf(vndwap) != -1
945
+ || httpAccept.indexOf(wml) != -1) {
879
946
  return true;
880
947
  }
881
948
  return false;
882
949
  }
883
950
 
884
951
  /**
885
- * Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
886
- * @return detection of a Maemo OS tablet
952
+ * Detects if the current device supports MIDP, a mobile Java technology.
953
+ * @return detection of a MIDP mobile Java-capable device
887
954
  */
888
- public boolean detectMaemoTablet() {
889
- if (userAgent.indexOf(maemo) != -1) {
890
- return true;
891
- } else if (userAgent.indexOf(linux) != -1
892
- && userAgent.indexOf(deviceTablet) != -1
893
- && !detectWebOSTablet()
894
- && !detectAndroid()) {
955
+ public boolean detectMidpCapable() {
956
+ if (userAgent.indexOf(deviceMidp) != -1
957
+ || httpAccept.indexOf(deviceMidp) != -1) {
895
958
  return true;
896
959
  }
897
960
  return false;
898
961
  }
899
962
 
963
+
964
+
965
+ //*****************************
966
+ // Device Classes
967
+ //*****************************
968
+
900
969
  /**
901
- * Detects if the current device is an Archos media player/Internet tablet.
902
- * @return detection of an Archos media player
970
+ * Check to see whether the device is any device
971
+ * in the 'smartphone' category.
972
+ * @return detection of a general smartphone device
903
973
  */
904
- public boolean detectArchos() {
905
- if (userAgent.indexOf(deviceArchos) != -1) {
906
- return true;
907
- }
908
- return false;
974
+ public boolean detectSmartphone() {
975
+ //Exclude duplicates from TierIphone
976
+ return (detectTierIphone()
977
+ || detectS60OssBrowser()
978
+ || detectSymbianOS()
979
+ || detectWindowsMobile()
980
+ || detectBlackBerry()
981
+ || detectPalmOS());
909
982
  }
910
983
 
911
984
  /**
912
- * Detects if the current browser is a Sony Mylo device.
913
- * @return detection of a Sony Mylo device
985
+ * Detects if the current device is a mobile device.
986
+ * This method catches most of the popular modern devices.
987
+ * Excludes Apple iPads and other modern tablets.
988
+ * @return detection of any mobile device using the quicker method
914
989
  */
915
- public boolean detectSonyMylo() {
916
- if (userAgent.indexOf(manuSony) != -1
917
- && (userAgent.indexOf(qtembedded) != -1
918
- || userAgent.indexOf(mylocom2) != -1)) {
990
+ public boolean detectMobileQuick() {
991
+ //Let's exclude tablets
992
+ if (detectTierTablet())
993
+ return false;
994
+
995
+ if ((initCompleted == true) ||
996
+ (isMobilePhone == true))
997
+ return isMobilePhone;
998
+
999
+ //Most mobile browsing is done on smartphones
1000
+ if (detectSmartphone())
919
1001
  return true;
920
- }
1002
+
1003
+ if (detectWapWml()
1004
+ || detectBrewDevice()
1005
+ || detectOperaMobile())
1006
+ return true;
1007
+
1008
+ if ((userAgent.indexOf(engineObigo) != -1)
1009
+ || (userAgent.indexOf(engineNetfront) != -1)
1010
+ || (userAgent.indexOf(engineUpBrowser) != -1)
1011
+ || (userAgent.indexOf(engineOpenWeb) != -1))
1012
+ return true;
1013
+
1014
+ if (detectDangerHiptop()
1015
+ || detectMidpCapable()
1016
+ || detectMaemoTablet()
1017
+ || detectArchos())
1018
+ return true;
1019
+
1020
+ if ((userAgent.indexOf(devicePda) != -1) &&
1021
+ (userAgent.indexOf(disUpdate) < 0)) //no index found
1022
+ return true;
1023
+
1024
+ if (userAgent.indexOf(mobile) != -1)
1025
+ return true;
1026
+
1027
+ //We also look for Kindle devices
1028
+ if (detectKindle()
1029
+ || detectAmazonSilk())
1030
+ return true;
1031
+
921
1032
  return false;
922
1033
  }
923
1034
 
@@ -938,28 +1049,21 @@ public class UAgentInfo {
938
1049
  }
939
1050
 
940
1051
  //detect older phones from certain manufacturers and operators.
941
- if (userAgent.indexOf(uplink) != -1) {
1052
+ if (userAgent.indexOf(uplink) != -1)
942
1053
  return true;
943
- }
944
- if (userAgent.indexOf(manuSonyEricsson) != -1) {
1054
+ if (userAgent.indexOf(manuSonyEricsson) != -1)
945
1055
  return true;
946
- }
947
- if (userAgent.indexOf(manuericsson) != -1) {
1056
+ if (userAgent.indexOf(manuericsson) != -1)
948
1057
  return true;
949
- }
950
- if (userAgent.indexOf(manuSamsung1) != -1) {
1058
+ if (userAgent.indexOf(manuSamsung1) != -1)
951
1059
  return true;
952
- }
953
1060
 
954
- if (userAgent.indexOf(svcDocomo) != -1) {
1061
+ if (userAgent.indexOf(svcDocomo) != -1)
955
1062
  return true;
956
- }
957
- if (userAgent.indexOf(svcKddi) != -1) {
1063
+ if (userAgent.indexOf(svcKddi) != -1)
958
1064
  return true;
959
- }
960
- if (userAgent.indexOf(svcVodafone) != -1) {
1065
+ if (userAgent.indexOf(svcVodafone) != -1)
961
1066
  return true;
962
- }
963
1067
 
964
1068
  return false;
965
1069
  }
@@ -976,6 +1080,10 @@ public class UAgentInfo {
976
1080
  * @return detection of any device in the Tablet Tier
977
1081
  */
978
1082
  public boolean detectTierTablet() {
1083
+ if ((this.initCompleted == true) ||
1084
+ (this.isTierTablet == true))
1085
+ return this.isTierTablet;
1086
+
979
1087
  if (detectIpad()
980
1088
  || detectAndroidTablet()
981
1089
  || detectBlackBerryTablet()
@@ -989,17 +1097,24 @@ public class UAgentInfo {
989
1097
  * The quick way to detect for a tier of devices.
990
1098
  * This method detects for devices which can
991
1099
  * display iPhone-optimized web content.
992
- * Includes iPhone, iPod Touch, Android, Windows Phone 7, Palm WebOS, etc.
993
- * @return detection of any device in the iPhone/Android/WP7/WebOS Tier
1100
+ * Includes iPhone, iPod Touch, Android, Windows Phone 7 and 8, BB10, WebOS, Playstation Vita, etc.
1101
+ * @return detection of any device in the iPhone/Android/Windows Phone/BlackBerry/WebOS Tier
994
1102
  */
995
1103
  public boolean detectTierIphone() {
996
- if (isIphone
997
- || isAndroidPhone
1104
+ if ((this.initCompleted == true) ||
1105
+ (this.isTierIphone == true))
1106
+ return this.isTierIphone;
1107
+
1108
+ if (detectIphoneOrIpod()
1109
+ || detectAndroidPhone()
1110
+ || detectWindowsPhone()
1111
+ || detectBlackBerry10Phone()
998
1112
  || (detectBlackBerryWebKit()
999
1113
  && detectBlackBerryTouch())
1000
- || detectWindowsPhone7()
1001
1114
  || detectPalmWebOS()
1002
- || detectGarminNuvifone()) {
1115
+ || detectBada()
1116
+ || detectTizen()
1117
+ || detectGamingHandheld()) {
1003
1118
  return true;
1004
1119
  }
1005
1120
  return false;
@@ -1014,12 +1129,17 @@ public class UAgentInfo {
1014
1129
  * @return detection of any device in the 'Rich CSS' Tier
1015
1130
  */
1016
1131
  public boolean detectTierRichCss() {
1132
+ if ((this.initCompleted == true) ||
1133
+ (this.isTierRichCss == true))
1134
+ return this.isTierRichCss;
1135
+
1017
1136
  boolean result = false;
1137
+
1018
1138
  //The following devices are explicitly ok.
1019
1139
  //Note: 'High' BlackBerry devices ONLY
1020
1140
  if (detectMobileQuick()) {
1021
1141
 
1022
- //Exclude iPhone Tier and e-Ink Kindle devices.
1142
+ //Exclude iPhone Tier and e-Ink Kindle devices.
1023
1143
  if (!detectTierIphone() && !detectKindle()) {
1024
1144
 
1025
1145
  //The following devices are explicitly ok.
@@ -1029,12 +1149,11 @@ public class UAgentInfo {
1029
1149
  || detectS60OssBrowser()
1030
1150
  || detectBlackBerryHigh()
1031
1151
  || detectWindowsMobile()
1032
- || userAgent.indexOf(engineTelecaQ) !=
1033
- -1) {
1152
+ || userAgent.indexOf(engineTelecaQ) != -1) {
1034
1153
  result= true;
1035
- } // if detectWebkit()
1036
- } //if !detectTierIphone()
1037
- } //if detectMobileQuick()
1154
+ }
1155
+ }
1156
+ }
1038
1157
  return result;
1039
1158
  }
1040
1159
 
@@ -1045,12 +1164,16 @@ public class UAgentInfo {
1045
1164
  * @return detection of a mobile device in the less capable tier
1046
1165
  */
1047
1166
  public boolean detectTierOtherPhones() {
1167
+ if ((this.initCompleted == true) ||
1168
+ (this.isTierGenericMobile == true))
1169
+ return this.isTierGenericMobile;
1170
+
1048
1171
  //Exclude devices in the other 2 categories
1049
1172
  if (detectMobileLong()
1050
1173
  && !detectTierIphone()
1051
- && !detectTierRichCss()) {
1174
+ && !detectTierRichCss())
1052
1175
  return true;
1053
- }
1176
+
1054
1177
  return false;
1055
1178
  }
1056
1179
  }