onfocusio-mobileesp_converted 0.2.3.onf2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1394 @@
1
+ # This file has been automatically converted to Ruby from Java source code.
2
+ #
3
+ #
4
+ #
5
+ =begin
6
+ *******************************************
7
+ # Copyright 2010-2015, Anthony Hand
8
+ #
9
+ #
10
+ # File version 2015.05.13 (May 13, 2015)
11
+ # Updates:
12
+ # - Moved MobileESP to GitHub. https:
13
+ # - Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet.
14
+ # - Removed DetectOperaAndroidPhone(). This method is no longer reliable.
15
+ # - Removed DetectOperaAndroidTablet(). This method is no longer reliable.
16
+ # - Added support for Windows Phone 10: variable and DetectWindowsPhone10()
17
+ # - Updated DetectWindowsPhone() to include WP10.
18
+ # - Added support for Firefox OS.
19
+ # - A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()
20
+ # - NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.
21
+ # - Added support for Sailfish OS. Not enough info to add a tablet detection method at this time.
22
+ # - A variable plus DetectSailfish(), DetectSailfishPhone()
23
+ # - Added support for Ubuntu Mobile OS.
24
+ # - DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()
25
+ # - Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps.
26
+ # - One variable for Samsung Tizen TVs, plus DetectTizenTV()
27
+ # - One variable for LG WebOS TVs, plus DetectWebOSTV()
28
+ # - Updated DetectTizen(). Now tests for "mobile" to disambiguate from Samsung Smart TVs
29
+ # - Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.
30
+ # - Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet.
31
+ # - Updated DetectAndroidPhone().
32
+ # - Updated internal detection code for Android.
33
+ # - No longer has a special test case for the HTC Flyer tablet.
34
+ # - Checks against DetectOperaMobile() on Android and reports here if relevant.
35
+ # - Updated DetectAndroidTablet().
36
+ # - No longer has a special test case for the HTC Flyer tablet.
37
+ # - Checks against DetectOperaMobile() on Android to exclude it from here.
38
+ # - DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones.
39
+ # - DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.
40
+ # - DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile.
41
+ # - DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile.
42
+ # - DetectSmartphone(): Added support for Meego phones.
43
+ # - Refactored the detection logic in DetectMobileQuick() and DetectMobileLong().
44
+ # - Moved a few detection tests for older browsers to Long.
45
+ #
46
+ #
47
+ #
48
+ # LICENSE INFORMATION
49
+ # Licensed under the Apache License, Version 2.0 (the "License")
50
+ # you may not use this file except in compliance with the License.
51
+ # You may obtain a copy of the License at
52
+ # http:
53
+ # Unless required by applicable law or agreed to in writing,
54
+ # software distributed under the License is distributed on an
55
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
56
+ # either express or implied. See the License for the specific
57
+ # language governing permissions and limitations under the License.
58
+ #
59
+ #
60
+ # ABOUT THIS PROJECT
61
+ # Project Owner: Anthony Hand
62
+ # Email: anthony.hand@gmail.com
63
+ # Web Site: http:
64
+ # Source Files: https:
65
+ #
66
+ # Versions of this code are available for:
67
+ # PHP, JavaScript, Java, ASP.NET (C#), and Ruby
68
+ #
69
+ # *******************************************
70
+
71
+ =end
72
+
73
+
74
+ =begin
75
+ *
76
+ * The DetectSmartPhone class encapsulates information about
77
+ * a browser's connection to your web site.
78
+ * You can use it to find out whether the browser asking for
79
+ * your site's content is probably running on a mobile device.
80
+ * The methods were written so you can be as granular as you want.
81
+ * For example, enquiring whether it's as specific as an iPod Touch or
82
+ * as general as a smartphone class device.
83
+ * The object's methods return true, or false.
84
+
85
+ =end
86
+ module MobileESPConverted
87
+ class UserAgentInfo
88
+
89
+
90
+ attr_reader :user_agent
91
+ attr_reader :http_accept
92
+
93
+
94
+ attr_reader :init_completed
95
+ attr_reader :is_webkit
96
+ attr_reader :is_mobile_phone
97
+ attr_reader :is_iphone
98
+ attr_reader :is_android
99
+ attr_reader :is_android_phone
100
+ attr_reader :is_tier_tablet
101
+ attr_reader :is_tier_iphone
102
+ attr_reader :is_tier_rich_css
103
+ attr_reader :is_tier_generic_mobile
104
+
105
+
106
+ ENGINE_WEB_KIT = "webkit"
107
+
108
+ DEVICE_IPHONE = "iphone"
109
+ DEVICE_IPOD = "ipod"
110
+ DEVICE_IPAD = "ipad"
111
+ DEVICE_MAC_PPC = "macintosh"
112
+
113
+ DEVICE_ANDROID = "android"
114
+ DEVICE_GOOGLE_T_V = "googletv"
115
+
116
+ DEVICE_WIN_PHONE7 = "windows phone os 7"
117
+ DEVICE_WIN_PHONE8 = "windows phone 8"
118
+ DEVICE_WIN_PHONE10 = "windows phone 10"
119
+ DEVICE_WIN_MOB = "windows ce"
120
+ DEVICE_WINDOWS = "windows"
121
+ DEVICE_IE_MOB = "iemobile"
122
+ DEVICE_PPC = "ppc"
123
+ ENGINE_PIE = "wm5 pie"
124
+
125
+ DEVICE_B_B = "blackberry"
126
+ DEVICE_B_B10 = "bb10"
127
+ VND_R_I_M = "vnd.rim"
128
+ DEVICE_B_B_STORM = "blackberry95"
129
+ DEVICE_B_B_BOLD = "blackberry97"
130
+ DEVICE_B_B_BOLD_TOUCH = "blackberry 99"
131
+ DEVICE_B_B_TOUR = "blackberry96"
132
+ DEVICE_B_B_CURVE = "blackberry89"
133
+ DEVICE_B_B_CURVE_TOUCH = "blackberry 938"
134
+ DEVICE_B_B_TORCH = "blackberry 98"
135
+ DEVICE_B_B_PLAYBOOK = "playbook"
136
+
137
+ DEVICE_SYMBIAN = "symbian"
138
+ DEVICE_S60 = "series60"
139
+ DEVICE_S70 = "series70"
140
+ DEVICE_S80 = "series80"
141
+ DEVICE_S90 = "series90"
142
+
143
+ DEVICE_PALM = "palm"
144
+ DEVICE_WEB_O_S = "webos"
145
+ DEVICE_WEB_O_STV = "web0s"
146
+ DEVICE_WEB_O_SHP = "hpwos"
147
+
148
+ DEVICE_NUVIFONE = "nuvifone"
149
+ DEVICE_BADA = "bada"
150
+ DEVICE_TIZEN = "tizen"
151
+ DEVICE_MEEGO = "meego"
152
+ DEVICE_SAILFISH = "sailfish"
153
+ DEVICE_UBUNTU = "ubuntu"
154
+
155
+ DEVICE_KINDLE = "kindle"
156
+ ENGINE_SILK = "silk-accelerated"
157
+
158
+ ENGINE_BLAZER = "blazer"
159
+ ENGINE_XIINO = "xiino"
160
+
161
+
162
+ VNDWAP = "vnd.wap"
163
+ WML = "wml"
164
+
165
+
166
+ DEVICE_TABLET = "tablet"
167
+ DEVICE_BREW = "brew"
168
+ DEVICE_DANGER = "danger"
169
+ DEVICE_HIPTOP = "hiptop"
170
+ DEVICE_PLAYSTATION = "playstation"
171
+ DEVICE_PLAYSTATION_VITA = "vita"
172
+ DEVICE_NINTENDO_DS = "nitro"
173
+ DEVICE_NINTENDO = "nintendo"
174
+ DEVICE_WII = "wii"
175
+ DEVICE_XBOX = "xbox"
176
+ DEVICE_ARCHOS = "archos"
177
+
178
+ ENGINE_FIREFOX = "firefox"
179
+ ENGINE_OPERA = "opera"
180
+ ENGINE_NETFRONT = "netfront"
181
+ ENGINE_UP_BROWSER = "up.browser"
182
+ ENGINE_OPEN_WEB = "openweb"
183
+ DEVICE_MIDP = "midp"
184
+ UPLINK = "up.link"
185
+ ENGINE_TELECA_Q = "teleca q"
186
+ DEVICE_PDA = "pda"
187
+ MINI = "mini"
188
+ MOBILE = "mobile"
189
+ MOBI = "mobi"
190
+
191
+
192
+ SMART_T_V1 = "smart-tv"
193
+ SMART_T_V2 = "smarttv"
194
+
195
+
196
+ MAEMO = "maemo"
197
+ LINUX = "linux"
198
+ QTEMBEDDED = "qt embedded"
199
+ MYLOCOM2 = "com2"
200
+
201
+
202
+ MANU_SONY_ERICSSON = "sonyericsson"
203
+ MANUERICSSON = "ericsson"
204
+ MANU_SAMSUNG1 = "sec-sgh"
205
+ MANU_SONY = "sony"
206
+ MANU_HTC = "htc"
207
+
208
+
209
+ SVC_DOCOMO = "docomo"
210
+ SVC_KDDI = "kddi"
211
+ SVC_VODAFONE = "vodafone"
212
+
213
+
214
+ DIS_UPDATE = "update"
215
+
216
+
217
+ =begin
218
+ *
219
+ * Initialize the user_agent and http_accept variables
220
+ *
221
+ * @param user_agent the User-Agent header
222
+ * @param http_accept the Accept header
223
+
224
+ =end
225
+ def initialize(user_agent, http_accept)
226
+ if (user_agent != nil)
227
+ @user_agent = user_agent.downcase
228
+ end
229
+ if (http_accept != nil)
230
+ @http_accept = http_accept.downcase
231
+ end
232
+
233
+
234
+ init_device_scan()
235
+ end
236
+
237
+ =begin
238
+ *
239
+ * Return the lower case HTTP_USER_AGENT
240
+ * @return user_agent
241
+
242
+ =end
243
+ def get_user_agent()
244
+ return user_agent
245
+ end
246
+
247
+ =begin
248
+ *
249
+ * Return the lower case HTTP_ACCEPT
250
+ * @return http_accept
251
+
252
+ =end
253
+ def get_http_accept()
254
+ return http_accept
255
+ end
256
+
257
+ =begin
258
+ *
259
+ * Return whether the device is an Iphone or iPod Touch
260
+ * @return is_iphone
261
+
262
+ =end
263
+ def get_is_iphone()
264
+ return is_iphone
265
+ end
266
+
267
+ =begin
268
+ *
269
+ * Return whether the device is in the Tablet Tier.
270
+ * @return is_tier_tablet
271
+
272
+ =end
273
+ def get_is_tier_tablet()
274
+ return is_tier_tablet
275
+ end
276
+
277
+ =begin
278
+ *
279
+ * Return whether the device is in the Iphone Tier.
280
+ * @return is_tier_iphone
281
+
282
+ =end
283
+ def get_is_tier_iphone()
284
+ return is_tier_iphone
285
+ end
286
+
287
+ =begin
288
+ *
289
+ * Return whether the device is in the 'Rich CSS' tier of mobile devices.
290
+ * @return is_tier_rich_css
291
+
292
+ =end
293
+ def get_is_tier_rich_css()
294
+ return is_tier_rich_css
295
+ end
296
+
297
+ =begin
298
+ *
299
+ * Return whether the device is a generic, less-capable mobile device.
300
+ * @return is_tier_generic_mobile
301
+
302
+ =end
303
+ def get_is_tier_generic_mobile()
304
+ return is_tier_generic_mobile
305
+ end
306
+
307
+ =begin
308
+ *
309
+ * Initialize Key Stored Values.
310
+
311
+ =end
312
+ def init_device_scan()
313
+
314
+ @is_webkit = detect_webkit()
315
+ @is_iphone = detect_iphone()
316
+ @is_android = detect_android()
317
+ @is_android_phone = detect_android_phone()
318
+
319
+
320
+ @is_mobile_phone = detect_mobile_quick()
321
+ @is_tier_tablet = detect_tier_tablet()
322
+ @is_tier_iphone = detect_tier_iphone()
323
+
324
+
325
+ @is_tier_rich_css = detect_tier_rich_css()
326
+ @is_tier_generic_mobile = detect_tier_other_phones()
327
+
328
+ @init_completed = true
329
+ end
330
+
331
+ =begin
332
+ *
333
+ * Detects if the current device is an iPhone.
334
+ * @return detection of an iPhone
335
+
336
+ =end
337
+ def detect_iphone()
338
+
339
+ if (user_agent.include?(DEVICE_IPHONE) &&
340
+ !detect_ipad() &&
341
+ !detect_ipod())
342
+ return true
343
+ end
344
+ return false
345
+ end
346
+
347
+ =begin
348
+ *
349
+ * Detects if the current device is an iPod Touch.
350
+ * @return detection of an iPod Touch
351
+
352
+ =end
353
+ def detect_ipod()
354
+ if (user_agent.include?(DEVICE_IPOD))
355
+ return true
356
+ end
357
+ return false
358
+ end
359
+
360
+ =begin
361
+ *
362
+ * Detects if the current device is an iPad tablet.
363
+ * @return detection of an iPad
364
+
365
+ =end
366
+ def detect_ipad()
367
+ if (user_agent.include?(DEVICE_IPAD) && detect_webkit())
368
+ return true
369
+ end
370
+ return false
371
+ end
372
+
373
+ =begin
374
+ *
375
+ * Detects if the current device is an iPhone or iPod Touch.
376
+ * @return detection of an iPhone or iPod Touch
377
+
378
+ =end
379
+ def detect_iphone_or_ipod()
380
+
381
+ if (detect_iphone() || user_agent.include?(DEVICE_IPOD))
382
+ return true
383
+ end
384
+ return false
385
+ end
386
+
387
+ =begin
388
+ *
389
+ * Detects *any* iOS device: iPhone, iPod Touch, iPad.
390
+ * @return detection of an Apple iOS device
391
+
392
+ =end
393
+ def detect_ios()
394
+ if (detect_iphone_or_ipod() || detect_ipad())
395
+ return true
396
+ end
397
+ return false
398
+ end
399
+
400
+
401
+ =begin
402
+ *
403
+ * Detects *any* Android OS-based device: phone, tablet, and multi-media player.
404
+ * Also detects Google TV.
405
+ * @return detection of an Android device
406
+
407
+ =end
408
+ def detect_android()
409
+ if ((user_agent.include?(DEVICE_ANDROID)) ||
410
+ detect_google_t_v())
411
+ return true
412
+ end
413
+
414
+ return false
415
+ end
416
+
417
+ =begin
418
+ *
419
+ * Detects if the current device is a (small-ish) Android OS-based device
420
+ * used for calling and/or multi-media (like a Samsung Galaxy Player).
421
+ * Google says these devices will have 'Android' AND 'mobile' in user agent.
422
+ * Ignores tablets (Honeycomb and later).
423
+ * @return detection of an Android phone
424
+
425
+ =end
426
+ def detect_android_phone()
427
+
428
+ if (!detect_android())
429
+ return false
430
+ end
431
+
432
+
433
+ if (user_agent.include?(MOBILE))
434
+ return true
435
+ end
436
+
437
+
438
+ if (detect_opera_mobile())
439
+ return true
440
+ end
441
+
442
+ return false
443
+ end
444
+
445
+ =begin
446
+ *
447
+ * Detects if the current device is a (self-reported) Android tablet.
448
+ * Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
449
+ * @return detection of an Android tablet
450
+
451
+ =end
452
+ def detect_android_tablet()
453
+
454
+ if (!detect_android())
455
+ return false
456
+ end
457
+
458
+
459
+ if (detect_opera_mobile())
460
+ return false
461
+ end
462
+
463
+
464
+ if ((user_agent.include?(MOBILE)))
465
+ return false
466
+ else
467
+ return true
468
+ end
469
+ end
470
+
471
+ =begin
472
+ *
473
+ * Detects if the current device is an Android OS-based device and
474
+ * the browser is based on WebKit.
475
+ * @return detection of an Android WebKit browser
476
+
477
+ =end
478
+ def detect_android_web_kit()
479
+ if (detect_android() && detect_webkit())
480
+ return true
481
+ end
482
+ return false
483
+ end
484
+
485
+ =begin
486
+ *
487
+ * Detects if the current device is a GoogleTV.
488
+ * @return detection of GoogleTV
489
+
490
+ =end
491
+ def detect_google_t_v()
492
+ if (user_agent.include?(DEVICE_GOOGLE_T_V))
493
+ return true
494
+ end
495
+ return false
496
+ end
497
+
498
+ =begin
499
+ *
500
+ * Detects if the current browser is based on WebKit.
501
+ * @return detection of a WebKit browser
502
+
503
+ =end
504
+ def detect_webkit()
505
+ if (user_agent.include?(ENGINE_WEB_KIT))
506
+ return true
507
+ end
508
+ return false
509
+ end
510
+
511
+ =begin
512
+ *
513
+ * Detects if the current browser is the Symbian S60 Open Source Browser.
514
+ * @return detection of Symbian S60 Browser
515
+
516
+ =end
517
+ def detect_s60_oss_browser()
518
+
519
+ if (detect_webkit() && (user_agent.include?(DEVICE_SYMBIAN) || user_agent.include?(DEVICE_S60)))
520
+ return true
521
+ end
522
+ return false
523
+ end
524
+
525
+ =begin
526
+ *
527
+ *
528
+ * Detects if the current device is any Symbian OS-based device,
529
+ * including older S60, Series 70, Series 80, Series 90, and UIQ,
530
+ * or other browsers running on these devices.
531
+ * @return detection of SymbianOS
532
+
533
+ =end
534
+ def detect_symbian_o_s()
535
+ if (user_agent.include?(DEVICE_SYMBIAN) || user_agent.include?(DEVICE_S60) || user_agent.include?(DEVICE_S70) || user_agent.include?(DEVICE_S80) || user_agent.include?(DEVICE_S90))
536
+ return true
537
+ end
538
+ return false
539
+ end
540
+
541
+ =begin
542
+ *
543
+ * Detects if the current browser is a Windows Phone 7.x, 8, or 10 device
544
+ * @return detection of Windows Phone 7.x OR 8
545
+
546
+ =end
547
+ def detect_windows_phone()
548
+ if (detect_windows_phone7() || detect_windows_phone8() || detect_windows_phone10())
549
+ return true
550
+ end
551
+ return false
552
+ end
553
+
554
+ =begin
555
+ *
556
+ * Detects a Windows Phone 7 device (in mobile browsing mode).
557
+ * @return detection of Windows Phone 7
558
+
559
+ =end
560
+ def detect_windows_phone7()
561
+ if (user_agent.include?(DEVICE_WIN_PHONE7))
562
+ return true
563
+ end
564
+ return false
565
+ end
566
+
567
+ =begin
568
+ *
569
+ * Detects a Windows Phone 8 device (in mobile browsing mode).
570
+ * @return detection of Windows Phone 8
571
+
572
+ =end
573
+ def detect_windows_phone8()
574
+ if (user_agent.include?(DEVICE_WIN_PHONE8))
575
+ return true
576
+ end
577
+ return false
578
+ end
579
+
580
+ =begin
581
+ *
582
+ * Detects a Windows Phone 10 device (in mobile browsing mode).
583
+ * @return detection of Windows Phone 10
584
+
585
+ =end
586
+ def detect_windows_phone10()
587
+ if (user_agent.include?(DEVICE_WIN_PHONE10))
588
+ return true
589
+ end
590
+ return false
591
+ end
592
+
593
+ =begin
594
+ *
595
+ * Detects if the current browser is a Windows Mobile device.
596
+ * Excludes Windows Phone 7.x and 8 devices.
597
+ * Focuses on Windows Mobile 6.xx and earlier.
598
+ * @return detection of Windows Mobile
599
+
600
+ =end
601
+ def detect_windows_mobile()
602
+ if (detect_windows_phone())
603
+ return false
604
+ end
605
+
606
+
607
+
608
+ if (user_agent.include?(DEVICE_WIN_MOB) || user_agent.include?(DEVICE_WIN_MOB) || user_agent.include?(DEVICE_IE_MOB) || user_agent.include?(ENGINE_PIE) || (user_agent.include?(MANU_HTC) && user_agent.include?(DEVICE_WINDOWS)) || (detect_wap_wml() && user_agent.include?(DEVICE_WINDOWS)))
609
+ return true
610
+ end
611
+
612
+
613
+ if (user_agent.include?(DEVICE_PPC) &&
614
+ !(user_agent.include?(DEVICE_MAC_PPC)))
615
+ return true
616
+ end
617
+
618
+ return false
619
+ end
620
+
621
+ =begin
622
+ *
623
+ * Detects if the current browser is any BlackBerry.
624
+ * Includes BB10 OS, but excludes the PlayBook.
625
+ * @return detection of Blackberry
626
+
627
+ =end
628
+ def detect_black_berry()
629
+ if (user_agent.include?(DEVICE_B_B) ||
630
+ http_accept.include?(VND_R_I_M))
631
+ return true
632
+ end
633
+
634
+ if (detect_black_berry10_phone())
635
+ return true
636
+ end
637
+
638
+ return false
639
+ end
640
+
641
+ =begin
642
+ *
643
+ * Detects if the current browser is a BlackBerry 10 OS phone.
644
+ * Excludes tablets.
645
+ * @return detection of a Blackberry 10 device
646
+
647
+ =end
648
+ def detect_black_berry10_phone()
649
+ if (user_agent.include?(DEVICE_B_B10) &&
650
+ user_agent.include?(MOBILE))
651
+ return true
652
+ end
653
+ return false
654
+ end
655
+
656
+ =begin
657
+ *
658
+ * Detects if the current browser is on a BlackBerry tablet device.
659
+ * Example: PlayBook
660
+ * @return detection of a Blackberry Tablet
661
+
662
+ =end
663
+ def detect_black_berry_tablet()
664
+ if (user_agent.include?(DEVICE_B_B_PLAYBOOK))
665
+ return true
666
+ end
667
+ return false
668
+ end
669
+
670
+ =begin
671
+ *
672
+ * Detects if the current browser is a BlackBerry device AND uses a
673
+ * WebKit-based browser. These are signatures for the new BlackBerry OS 6.
674
+ * Examples: Torch. Includes the Playbook.
675
+ * @return detection of a Blackberry device with WebKit browser
676
+
677
+ =end
678
+ def detect_black_berry_web_kit()
679
+ if (detect_black_berry() &&
680
+ user_agent.include?(ENGINE_WEB_KIT))
681
+ return true
682
+ end
683
+ return false
684
+ end
685
+
686
+ =begin
687
+ *
688
+ * Detects if the current browser is a BlackBerry Touch
689
+ * device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
690
+ * @return detection of a Blackberry touchscreen device
691
+
692
+ =end
693
+ def detect_black_berry_touch()
694
+ if (detect_black_berry() &&
695
+ (user_agent.include?(DEVICE_B_B_STORM) ||
696
+ user_agent.include?(DEVICE_B_B_TORCH) ||
697
+ user_agent.include?(DEVICE_B_B_BOLD_TOUCH) ||
698
+ user_agent.include?(DEVICE_B_B_CURVE_TOUCH) ))
699
+ return true
700
+ end
701
+ return false
702
+ end
703
+
704
+ =begin
705
+ *
706
+ * Detects if the current browser is a BlackBerry device AND
707
+ * has a more capable recent browser. Excludes the Playbook.
708
+ * Examples, Storm, Bold, Tour, Curve2
709
+ * Excludes the new BlackBerry OS 6 and 7 browser!!
710
+ * @return detection of a Blackberry device with a better browser
711
+
712
+ =end
713
+ def detect_black_berry_high()
714
+
715
+ if (detect_black_berry_web_kit())
716
+ return false
717
+ end
718
+ if (detect_black_berry())
719
+ if (detect_black_berry_touch() || user_agent.include?(DEVICE_B_B_BOLD) || user_agent.include?(DEVICE_B_B_TOUR) || user_agent.include?(DEVICE_B_B_CURVE))
720
+ return true
721
+ else
722
+ return false
723
+ end
724
+ else
725
+ return false
726
+ end
727
+ end
728
+
729
+ =begin
730
+ *
731
+ * Detects if the current browser is a BlackBerry device AND
732
+ * has an older, less capable browser.
733
+ * Examples: Pearl, 8800, Curve1
734
+ * @return detection of a Blackberry device with a poorer browser
735
+
736
+ =end
737
+ def detect_black_berry_low()
738
+ if (detect_black_berry())
739
+
740
+ if (detect_black_berry_high() || detect_black_berry_web_kit())
741
+ return false
742
+ else
743
+ return true
744
+ end
745
+ else
746
+ return false
747
+ end
748
+ end
749
+
750
+ =begin
751
+ *
752
+ * Detects if the current browser is on a PalmOS device.
753
+ * @return detection of a PalmOS device
754
+
755
+ =end
756
+ def detect_palm_o_s()
757
+
758
+ if (user_agent.include?(DEVICE_PALM) || user_agent.include?(ENGINE_BLAZER) || user_agent.include?(ENGINE_XIINO))
759
+
760
+ if (detect_palm_web_o_s())
761
+ return false
762
+ else
763
+ return true
764
+ end
765
+ end
766
+ return false
767
+ end
768
+
769
+ =begin
770
+ *
771
+ * Detects if the current browser is on a Palm device
772
+ * running the new WebOS.
773
+ * @return detection of a Palm WebOS device
774
+
775
+ =end
776
+ def detect_palm_web_o_s()
777
+ if (user_agent.include?(DEVICE_WEB_O_S))
778
+ return true
779
+ end
780
+ return false
781
+ end
782
+
783
+ =begin
784
+ *
785
+ * Detects if the current browser is on an HP tablet running WebOS.
786
+ * @return detection of an HP WebOS tablet
787
+
788
+ =end
789
+ def detect_web_o_s_tablet()
790
+ if (user_agent.include?(DEVICE_WEB_O_SHP) &&
791
+ user_agent.include?(DEVICE_TABLET))
792
+ return true
793
+ end
794
+ return false
795
+ end
796
+
797
+ =begin
798
+ *
799
+ * Detects if the current browser is on a WebOS smart TV.
800
+ * @return detection of a WebOS smart TV
801
+
802
+ =end
803
+ def detect_web_o_s_t_v()
804
+ if (user_agent.include?(DEVICE_WEB_O_STV) &&
805
+ user_agent.include?(SMART_T_V2))
806
+ return true
807
+ end
808
+ return false
809
+ end
810
+
811
+ =begin
812
+ *
813
+ * Detects Opera Mobile or Opera Mini.
814
+ * @return detection of an Opera browser for a mobile device
815
+
816
+ =end
817
+ def detect_opera_mobile()
818
+ if (user_agent.include?(ENGINE_OPERA) && (user_agent.include?(MINI) || user_agent.include?(MOBI)))
819
+ return true
820
+ end
821
+ return false
822
+ end
823
+
824
+ =begin
825
+ *
826
+ * Detects if the current device is an Amazon Kindle (eInk devices only).
827
+ * Note: For the Kindle Fire, use the normal Android methods.
828
+ * @return detection of a Kindle
829
+
830
+ =end
831
+ def detect_kindle()
832
+ if (user_agent.include?(DEVICE_KINDLE) &&
833
+ !detect_android())
834
+ return true
835
+ end
836
+ return false
837
+ end
838
+
839
+ =begin
840
+ *
841
+ * Detects if the current Amazon device is using the Silk Browser.
842
+ * Note: Typically used by the the Kindle Fire.
843
+ * @return detection of an Amazon Kindle Fire in Silk mode.
844
+
845
+ =end
846
+ def detect_amazon_silk()
847
+ if (user_agent.include?(ENGINE_SILK))
848
+ return true
849
+ end
850
+ return false
851
+ end
852
+
853
+ =begin
854
+ *
855
+ * Detects if the current browser is a
856
+ * Garmin Nuvifone.
857
+ * @return detection of a Garmin Nuvifone
858
+
859
+ =end
860
+ def detect_garmin_nuvifone()
861
+ if (user_agent.include?(DEVICE_NUVIFONE))
862
+ return true
863
+ end
864
+ return false
865
+ end
866
+
867
+ =begin
868
+ *
869
+ * Detects a device running the Bada OS from Samsung.
870
+ * @return detection of a Bada device
871
+
872
+ =end
873
+ def detect_bada()
874
+ if (user_agent.include?(DEVICE_BADA))
875
+ return true
876
+ end
877
+ return false
878
+ end
879
+
880
+ =begin
881
+ *
882
+ * Detects a device running the Tizen smartphone OS.
883
+ * @return detection of a Tizen device
884
+
885
+ =end
886
+ def detect_tizen()
887
+ if (user_agent.include?(DEVICE_TIZEN) &&
888
+ user_agent.include?(MOBILE))
889
+ return true
890
+ end
891
+ return false
892
+ end
893
+
894
+ =begin
895
+ *
896
+ * Detects if the current browser is on a Tizen smart TV.
897
+ * @return detection of a Tizen smart TV
898
+
899
+ =end
900
+ def detect_tizen_t_v()
901
+ if (user_agent.include?(DEVICE_TIZEN) &&
902
+ user_agent.include?(SMART_T_V1))
903
+ return true
904
+ end
905
+ return false
906
+ end
907
+
908
+ =begin
909
+ *
910
+ * Detects a device running the Meego OS.
911
+ * @return detection of a Meego device
912
+
913
+ =end
914
+ def detect_meego()
915
+ if (user_agent.include?(DEVICE_MEEGO))
916
+ return true
917
+ end
918
+ return false
919
+ end
920
+
921
+ =begin
922
+ *
923
+ * Detects a phone running the Meego OS.
924
+ * @return detection of a Meego phone
925
+
926
+ =end
927
+ def detect_meego_phone()
928
+ if (user_agent.include?(DEVICE_MEEGO) &&
929
+ user_agent.include?(MOBI))
930
+ return true
931
+ end
932
+ return false
933
+ end
934
+
935
+ =begin
936
+ *
937
+ * Detects a mobile device (probably) running the Firefox OS.
938
+ * @return detection of a Firefox OS mobile device
939
+
940
+ =end
941
+ def detect_firefox_o_s()
942
+ if (detect_firefox_o_s_phone() || detect_firefox_o_s_tablet())
943
+ return true
944
+ end
945
+
946
+ return false
947
+ end
948
+
949
+ =begin
950
+ *
951
+ * Detects a phone (probably) running the Firefox OS.
952
+ * @return detection of a Firefox OS phone
953
+
954
+ =end
955
+ def detect_firefox_o_s_phone()
956
+
957
+ if (detect_ios() || detect_android() || detect_sailfish())
958
+ return false
959
+ end
960
+
961
+ if ((user_agent.include?(ENGINE_FIREFOX)) && (user_agent.include?(MOBILE)))
962
+ return true
963
+ end
964
+
965
+ return false
966
+ end
967
+
968
+ =begin
969
+ *
970
+ * Detects a tablet (probably) running the Firefox OS.
971
+ * @return detection of a Firefox OS tablet
972
+
973
+ =end
974
+ def detect_firefox_o_s_tablet()
975
+
976
+ if (detect_ios() || detect_android() || detect_sailfish())
977
+ return false
978
+ end
979
+
980
+ if ((user_agent.include?(ENGINE_FIREFOX)) && (user_agent.include?(DEVICE_TABLET)))
981
+ return true
982
+ end
983
+
984
+ return false
985
+ end
986
+
987
+ =begin
988
+ *
989
+ * Detects a device running the Sailfish OS.
990
+ * @return detection of a Sailfish device
991
+
992
+ =end
993
+ def detect_sailfish()
994
+ if (user_agent.include?(DEVICE_SAILFISH))
995
+ return true
996
+ end
997
+ return false
998
+ end
999
+
1000
+ =begin
1001
+ *
1002
+ * Detects a phone running the Sailfish OS.
1003
+ * @return detection of a Sailfish phone
1004
+
1005
+ =end
1006
+ def detect_sailfish_phone()
1007
+ if (detect_sailfish() && (user_agent.include?(MOBILE)))
1008
+ return true
1009
+ end
1010
+
1011
+ return false
1012
+ end
1013
+
1014
+ =begin
1015
+ *
1016
+ * Detects a mobile device running the Ubuntu Mobile OS.
1017
+ * @return detection of an Ubuntu Mobile OS mobile device
1018
+
1019
+ =end
1020
+ def detect_ubuntu()
1021
+ if (detect_ubuntu_phone() || detect_ubuntu_tablet())
1022
+ return true
1023
+ end
1024
+
1025
+ return false
1026
+ end
1027
+
1028
+ =begin
1029
+ *
1030
+ * Detects a phone running the Ubuntu Mobile OS.
1031
+ * @return detection of an Ubuntu Mobile OS phone
1032
+
1033
+ =end
1034
+ def detect_ubuntu_phone()
1035
+ if ((user_agent.include?(DEVICE_UBUNTU)) && (user_agent.include?(MOBILE)))
1036
+ return true
1037
+ end
1038
+
1039
+ return false
1040
+ end
1041
+
1042
+ =begin
1043
+ *
1044
+ * Detects a tablet running the Ubuntu Mobile OS.
1045
+ * @return detection of an Ubuntu Mobile OS tablet
1046
+
1047
+ =end
1048
+ def detect_ubuntu_tablet()
1049
+ if ((user_agent.include?(DEVICE_UBUNTU)) && (user_agent.include?(DEVICE_TABLET)))
1050
+ return true
1051
+ end
1052
+
1053
+ return false
1054
+ end
1055
+
1056
+
1057
+ =begin
1058
+ *
1059
+ * Detects the Danger Hiptop device.
1060
+ * @return detection of a Danger Hiptop
1061
+
1062
+ =end
1063
+ def detect_danger_hiptop()
1064
+ if (user_agent.include?(DEVICE_DANGER) || user_agent.include?(DEVICE_HIPTOP))
1065
+ return true
1066
+ end
1067
+ return false
1068
+ end
1069
+
1070
+ =begin
1071
+ *
1072
+ * Detects if the current browser is a Sony Mylo device.
1073
+ * @return detection of a Sony Mylo device
1074
+
1075
+ =end
1076
+ def detect_sony_mylo()
1077
+ if (user_agent.include?(MANU_SONY) && (user_agent.include?(QTEMBEDDED) || user_agent.include?(MYLOCOM2)))
1078
+ return true
1079
+ end
1080
+ return false
1081
+ end
1082
+
1083
+ =begin
1084
+ *
1085
+ * Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
1086
+ * @return detection of a Maemo OS tablet
1087
+
1088
+ =end
1089
+ def detect_maemo_tablet()
1090
+ if (user_agent.include?(MAEMO))
1091
+ return true
1092
+ elsif (user_agent.include?(LINUX) && user_agent.include?(DEVICE_TABLET) && !detect_web_o_s_tablet() && !detect_android())
1093
+ return true
1094
+ end
1095
+ return false
1096
+ end
1097
+
1098
+ =begin
1099
+ *
1100
+ * Detects if the current device is an Archos media player/Internet tablet.
1101
+ * @return detection of an Archos media player
1102
+
1103
+ =end
1104
+ def detect_archos()
1105
+ if (user_agent.include?(DEVICE_ARCHOS))
1106
+ return true
1107
+ end
1108
+ return false
1109
+ end
1110
+
1111
+ =begin
1112
+ *
1113
+ * Detects if the current device is an Internet-capable game console.
1114
+ * Includes many handheld consoles.
1115
+ * @return detection of any Game Console
1116
+
1117
+ =end
1118
+ def detect_game_console()
1119
+ if (detect_sony_playstation() || detect_nintendo() || detect_xbox())
1120
+ return true
1121
+ end
1122
+ return false
1123
+ end
1124
+
1125
+ =begin
1126
+ *
1127
+ * Detects if the current device is a Sony Playstation.
1128
+ * @return detection of Sony Playstation
1129
+
1130
+ =end
1131
+ def detect_sony_playstation()
1132
+ if (user_agent.include?(DEVICE_PLAYSTATION))
1133
+ return true
1134
+ end
1135
+ return false
1136
+ end
1137
+
1138
+ =begin
1139
+ *
1140
+ * Detects if the current device is a handheld gaming device with
1141
+ * a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
1142
+ * @return detection of a handheld gaming device
1143
+
1144
+ =end
1145
+ def detect_gaming_handheld()
1146
+ if ((user_agent.include?(DEVICE_PLAYSTATION)) &&
1147
+ (user_agent.include?(DEVICE_PLAYSTATION_VITA)))
1148
+ return true
1149
+ end
1150
+ return false
1151
+ end
1152
+
1153
+ =begin
1154
+ *
1155
+ * Detects if the current device is a Nintendo game device.
1156
+ * @return detection of Nintendo
1157
+
1158
+ =end
1159
+ def detect_nintendo()
1160
+ if (user_agent.include?(DEVICE_NINTENDO) || user_agent.include?(DEVICE_WII) || user_agent.include?(DEVICE_NINTENDO_DS))
1161
+ return true
1162
+ end
1163
+ return false
1164
+ end
1165
+
1166
+ =begin
1167
+ *
1168
+ * Detects if the current device is a Microsoft Xbox.
1169
+ * @return detection of Xbox
1170
+
1171
+ =end
1172
+ def detect_xbox()
1173
+ if (user_agent.include?(DEVICE_XBOX))
1174
+ return true
1175
+ end
1176
+ return false
1177
+ end
1178
+
1179
+ =begin
1180
+ *
1181
+ * Detects whether the device is a Brew-powered device.
1182
+ * @return detection of a Brew device
1183
+
1184
+ =end
1185
+ def detect_brew_device()
1186
+ if (user_agent.include?(DEVICE_BREW))
1187
+ return true
1188
+ end
1189
+ return false
1190
+ end
1191
+
1192
+ =begin
1193
+ *
1194
+ * Detects whether the device supports WAP or WML.
1195
+ * @return detection of a WAP- or WML-capable device
1196
+
1197
+ =end
1198
+ def detect_wap_wml()
1199
+ if (http_accept.include?(VNDWAP) || http_accept.include?(WML))
1200
+ return true
1201
+ end
1202
+ return false
1203
+ end
1204
+
1205
+ =begin
1206
+ *
1207
+ * Detects if the current device supports MIDP, a mobile Java technology.
1208
+ * @return detection of a MIDP mobile Java-capable device
1209
+
1210
+ =end
1211
+ def detect_midp_capable()
1212
+ if (user_agent.include?(DEVICE_MIDP) || http_accept.include?(DEVICE_MIDP))
1213
+ return true
1214
+ end
1215
+ return false
1216
+ end
1217
+
1218
+
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+ =begin
1225
+ *
1226
+ * Check to see whether the device is any device
1227
+ * in the 'smartphone' category.
1228
+ * @return detection of a general smartphone device
1229
+
1230
+ =end
1231
+ def detect_smartphone()
1232
+
1233
+ return (detect_tier_iphone() || detect_s60_oss_browser() || detect_symbian_o_s() || detect_windows_mobile() || detect_black_berry() || detect_meego_phone() || detect_palm_o_s())
1234
+ end
1235
+
1236
+ =begin
1237
+ *
1238
+ * Detects if the current device is a mobile device.
1239
+ * This method catches most of the popular modern devices.
1240
+ * Excludes Apple iPads and other modern tablets.
1241
+ * @return detection of any mobile device using the quicker method
1242
+
1243
+ =end
1244
+ def detect_mobile_quick()
1245
+
1246
+ if (is_tier_tablet)
1247
+ return false
1248
+ end
1249
+
1250
+ if (detect_smartphone())
1251
+ return true
1252
+ end
1253
+
1254
+
1255
+ if (user_agent.include?(MOBILE))
1256
+ return true
1257
+ end
1258
+
1259
+ if (detect_opera_mobile())
1260
+ return true
1261
+ end
1262
+
1263
+
1264
+ if (detect_kindle() || detect_amazon_silk())
1265
+ return true
1266
+ end
1267
+
1268
+ if (detect_wap_wml() || detect_midp_capable() || detect_brew_device())
1269
+ return true
1270
+ end
1271
+
1272
+ if ((user_agent.include?(ENGINE_NETFRONT)) || (user_agent.include?(ENGINE_UP_BROWSER)))
1273
+ return true
1274
+ end
1275
+
1276
+ return false
1277
+ end
1278
+
1279
+ =begin
1280
+ *
1281
+ * The longer and more thorough way to detect for a mobile device.
1282
+ * Will probably detect most feature phones,
1283
+ * smartphone-class devices, Internet Tablets,
1284
+ * Internet-enabled game consoles, etc.
1285
+ * This ought to catch a lot of the more obscure and older devices, also --
1286
+ * but no promises on thoroughness!
1287
+ * @return detection of any mobile device using the more thorough method
1288
+
1289
+ =end
1290
+ def detect_mobile_long()
1291
+ if (detect_mobile_quick() || detect_game_console())
1292
+ return true
1293
+ end
1294
+
1295
+ if (detect_danger_hiptop() || detect_maemo_tablet() || detect_sony_mylo() || detect_archos())
1296
+ return true
1297
+ end
1298
+
1299
+ if ((user_agent.include?(DEVICE_PDA)) &&
1300
+ (!user_agent.include?(DIS_UPDATE)))
1301
+ return true
1302
+ end
1303
+
1304
+
1305
+ if ((user_agent.include?(UPLINK)) || (user_agent.include?(ENGINE_OPEN_WEB)) || (user_agent.include?(MANU_SAMSUNG1)) || (user_agent.include?(MANU_SONY_ERICSSON)) || (user_agent.include?(MANUERICSSON)) || (user_agent.include?(SVC_DOCOMO)) || (user_agent.include?(SVC_KDDI)) || (user_agent.include?(SVC_VODAFONE)))
1306
+ return true
1307
+ end
1308
+
1309
+ return false
1310
+ end
1311
+
1312
+
1313
+
1314
+
1315
+
1316
+ =begin
1317
+ *
1318
+ * The quick way to detect for a tier of devices.
1319
+ * This method detects for the new generation of
1320
+ * HTML 5 capable, larger screen tablets.
1321
+ * Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.
1322
+ * @return detection of any device in the Tablet Tier
1323
+
1324
+ =end
1325
+ def detect_tier_tablet()
1326
+ if (detect_ipad() || detect_android_tablet() || detect_black_berry_tablet() || detect_firefox_o_s_tablet() || detect_ubuntu_tablet() || detect_web_o_s_tablet())
1327
+ return true
1328
+ end
1329
+ return false
1330
+ end
1331
+
1332
+ =begin
1333
+ *
1334
+ * The quick way to detect for a tier of devices.
1335
+ * This method detects for devices which can
1336
+ * display iPhone-optimized web content.
1337
+ * Includes iPhone, iPod Touch, Android, Windows Phone 7 and 8, BB10, WebOS, Playstation Vita, etc.
1338
+ * @return detection of any device in the iPhone/Android/Windows Phone/BlackBerry/WebOS Tier
1339
+
1340
+ =end
1341
+ def detect_tier_iphone()
1342
+ if (detect_iphone_or_ipod() || detect_android_phone() || detect_windows_phone() || detect_black_berry10_phone() || (detect_black_berry_web_kit() && detect_black_berry_touch()) || detect_palm_web_o_s() || detect_bada() || detect_tizen() || detect_firefox_o_s_phone() || detect_sailfish_phone() || detect_ubuntu_phone() || detect_gaming_handheld())
1343
+ return true
1344
+ end
1345
+ return false
1346
+ end
1347
+
1348
+ =begin
1349
+ *
1350
+ * The quick way to detect for a tier of devices.
1351
+ * This method detects for devices which are likely to be capable
1352
+ * of viewing CSS content optimized for the iPhone,
1353
+ * but may not necessarily support JavaScript.
1354
+ * Excludes all iPhone Tier devices.
1355
+ * @return detection of any device in the 'Rich CSS' Tier
1356
+
1357
+ =end
1358
+ def detect_tier_rich_css()
1359
+ result = false
1360
+
1361
+
1362
+ if (detect_mobile_quick())
1363
+
1364
+
1365
+ if (!detect_tier_iphone() && !detect_kindle())
1366
+
1367
+
1368
+
1369
+
1370
+ if (detect_webkit() || detect_s60_oss_browser() || detect_black_berry_high() || detect_windows_mobile() || user_agent.include?(ENGINE_TELECA_Q))
1371
+ result= true
1372
+ end
1373
+ end
1374
+ end
1375
+ return result
1376
+ end
1377
+
1378
+ =begin
1379
+ *
1380
+ * The quick way to detect for a tier of devices.
1381
+ * This method detects for all other types of phones,
1382
+ * but excludes the iPhone and RichCSS Tier devices.
1383
+ * @return detection of a mobile device in the less capable tier
1384
+
1385
+ =end
1386
+ def detect_tier_other_phones()
1387
+
1388
+ if (detect_mobile_long() && !detect_tier_iphone() && !detect_tier_rich_css())
1389
+ return true
1390
+ end
1391
+ return false
1392
+ end
1393
+ end
1394
+ end