Skip to content

Commit c2ff01d

Browse files
committed
Warn Android WebView users about bugs + unofficial app
Rel: freeCodeCamp#388
1 parent 2813cf9 commit c2ff01d

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

assets/javascripts/app/app.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@
245245
isMobile: ->
246246
@_isMobile ?= app.views.Mobile.detect()
247247

248+
isAndroidWebview: ->
249+
@_isAndroidWebview ?= app.views.Mobile.detectAndroidWebview()
250+
248251
isInvalidLocation: ->
249252
@config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
250253

assets/javascripts/templates/pages/root_tmpl.coffee.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,12 @@ app.templates.mobileIntro = """
7373
<a class="_intro-hide" data-hide-intro>Stop showing this message</a>
7474
</div>
7575
"""
76+
77+
app.templates.androidWarning = """
78+
<div class="_mobile-intro">
79+
<h2 class="_intro-title">Hi there</h2>
80+
<p>DevDocs is running inside an Android WebView. Some features may not work properly.
81+
<p>If you downloaded an app called DevDocs on the Play Store, please uninstall it — it's made by someone who is using (and profiting from) the name DevDocs without permission.
82+
<p>To install DevDocs on your phone, visit <a href="http://devdocs.io" target="_blank">devdocs.io</a> in Chrome and select "Add to home screen" in the menu.
83+
</div>
84+
"""

assets/javascripts/views/content/root_page.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class app.views.RootPage extends app.View
1010
render: ->
1111
@empty()
1212
@append @tmpl('mobileNav') if app.isMobile()
13-
@append @tmpl if @isHidden() then 'splash' else if app.isMobile() then 'mobileIntro' else 'intro'
13+
if app.isAndroidWebview()
14+
@append @tmpl('androidWarning')
15+
else
16+
@append @tmpl if @isHidden() then 'splash' else if app.isMobile() then 'mobileIntro' else 'intro'
1417
return
1518

1619
hideIntro: ->

assets/javascripts/views/layout/mobile.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ class app.views.Mobile extends app.View
2121
catch
2222
false
2323

24+
@detectAndroidWebview: ->
25+
try
26+
/(Android).*( Version\/.\.. ).*(Chrome)/.test(navigator.userAgent)
27+
catch
28+
false
29+
2430
constructor: ->
2531
@el = document.documentElement
2632
super

0 commit comments

Comments
 (0)