History

Warn Android WebView users about bugs + unofficial app

Thibaut Courouble committed 10 years ago

Commit c2ff01d1 parent 2813cf94 files · +22 −1Browse files

Unified · Split

4 files
  1. assets/javascripts/app/app.coffee +3 −0
  2. assets/javascripts/templates/pages/root_tmpl.coffee.erb +9 −0
  3. assets/javascripts/views/content/root_page.coffee +4 −1
  4. assets/javascripts/views/layout/mobile.coffee +6 −0
assets/javascripts/app/app.coffee+3−0
@@ -245,6 +245,9 @@ · 244 unmodified lines
245 isMobile: ->245 isMobile: ->
246 @_isMobile ?= app.views.Mobile.detect()246 @_isMobile ?= app.views.Mobile.detect()
247 247
248 isAndroidWebview: ->
249 @_isAndroidWebview ?= app.views.Mobile.detectAndroidWebview()
250
248 isInvalidLocation: ->251 isInvalidLocation: ->
249 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0252 @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
250 253
assets/javascripts/templates/pages/root_tmpl.coffee.erb+9−0
@@ -73,3 +73,12 @@ app.templates.mobileIntro = """ · 72 unmodified lines
73 <a class="_intro-hide" data-hide-intro>Stop showing this message</a>73 <a class="_intro-hide" data-hide-intro>Stop showing this message</a>
74 </div>74 </div>
75"""75"""
76
77app.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+4−1
@@ -10,7 +10,10 @@ class app.views.RootPage extends app.View · 9 unmodified lines
10 render: ->10 render: ->
11 @empty()11 @empty()
12 @append @tmpl('mobileNav') if app.isMobile()12 @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'
14 return17 return
15 18
16 hideIntro: ->19 hideIntro: ->
assets/javascripts/views/layout/mobile.coffee+6−0
@@ -21,6 +21,12 @@ class app.views.Mobile extends app.View · 20 unmodified lines
21 catch21 catch
22 false22 false
23 23
24 @detectAndroidWebview: ->
25 try
26 /(Android).*( Version\/.\.. ).*(Chrome)/.test(navigator.userAgent)
27 catch
28 false
29
24 constructor: ->30 constructor: ->
25 @el = document.documentElement31 @el = document.documentElement
26 super32 super