Browse Source

Warn Android WebView users about bugs + unofficial app

Rel: #388
Thibaut Courouble 9 years ago
parent
commit
c2ff01d73f

+ 3 - 0
assets/javascripts/app/app.coffee

@@ -245,6 +245,9 @@
   isMobile: ->
     @_isMobile ?= app.views.Mobile.detect()
 
+  isAndroidWebview: ->
+    @_isAndroidWebview ?= app.views.Mobile.detectAndroidWebview()
+
   isInvalidLocation: ->
     @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
 

+ 9 - 0
assets/javascripts/templates/pages/root_tmpl.coffee.erb

@@ -73,3 +73,12 @@ app.templates.mobileIntro = """
     <a class="_intro-hide" data-hide-intro>Stop showing this message</a>
   </div>
 """
+
+app.templates.androidWarning = """
+  <div class="_mobile-intro">
+    <h2 class="_intro-title">Hi there</h2>
+    <p>DevDocs is running inside an Android WebView. Some features may not work properly.
+    <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.
+    <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.
+  </div>
+"""

+ 4 - 1
assets/javascripts/views/content/root_page.coffee

@@ -10,7 +10,10 @@ class app.views.RootPage extends app.View
   render: ->
     @empty()
     @append @tmpl('mobileNav') if app.isMobile()
-    @append @tmpl if @isHidden() then 'splash' else if app.isMobile() then 'mobileIntro' else 'intro'
+    if app.isAndroidWebview()
+      @append @tmpl('androidWarning')
+    else
+      @append @tmpl if @isHidden() then 'splash' else if app.isMobile() then 'mobileIntro' else 'intro'
     return
 
   hideIntro: ->

+ 6 - 0
assets/javascripts/views/layout/mobile.coffee

@@ -21,6 +21,12 @@ class app.views.Mobile extends app.View
     catch
       false
 
+  @detectAndroidWebview: ->
+    try
+      /(Android).*( Version\/.\.. ).*(Chrome)/.test(navigator.userAgent)
+    catch
+      false
+
   constructor: ->
     @el = document.documentElement
     super