File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
kolibri/plugins/learn/assets/src/views/content-page Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 142142 },
143143 data : () => ({ wasIncomplete: false }),
144144 computed: {
145+ /**
146+ * Detects whether an Android device is using WebView.
147+ * Based on https://developer.chrome.com/multidevice/user-agent#webview_user_agent
148+ */
149+ isAndroidWebView () {
150+ const ua = window .navigator .userAgent ;
151+ const isAndroid = / Android/ .test (ua);
152+
153+ if (isAndroid) {
154+ const androidVersion = parseFloat (ua .match (/ Android\s ([0-9 \. ] * )/ )[1 ]);
155+ const isChrome = / Chrome/ .test (ua);
156+
157+ // WebView UA in Lollipop and Above
158+ // Android >=5.0
159+ if (androidVersion >= 5.0 && isChrome && / wv/ .test (ua)) {
160+ return true ;
161+ }
162+
163+ // WebView UA in KitKat to Lollipop
164+ // Android >= 4.4
165+ if (androidVersion >= 4.4 && androidVersion < 5.0 && isChrome && / Version\/ / .test (ua)) {
166+ return true ;
167+ }
168+
169+ // Old WebView UA
170+ // Android < 4.4
171+ if (androidVersion < 4.4 && / Version\/ / .test (ua) && / \/ 534. 30/ .test (ua)) {
172+ return true ;
173+ }
174+ }
175+
176+ return false ;
177+ },
145178 canDownload () {
146179 if (this .content ) {
147- return this .content .kind !== ContentNodeKinds .EXERCISE ;
180+ return this .content .kind !== ContentNodeKinds .EXERCISE && ! this . isAndroidWebView ;
148181 }
149182 return false ;
150183 },
You can’t perform that action at this time.
0 commit comments