Skip to content

Commit 4922b37

Browse files
author
Thorn Walli
committed
fix(device): improve android message and ios safari detection
1 parent 2989427 commit 4922b37

File tree

5 files changed

+60
-21
lines changed

5 files changed

+60
-21
lines changed

src/components/atoms/InfoBox.vue

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ import RichText from '@/components/atoms/RichText';
1919
export default {
2020
components: { TextFade, RichText },
2121
props: {
22-
error: {
23-
type: Boolean,
24-
default: false
25-
},
2622
fade: {
2723
type: Boolean,
2824
default: false
@@ -47,8 +43,7 @@ export default {
4743
computed: {
4844
styleClasses () {
4945
return {
50-
[`info-box--${this.styleType}`]: this.styleType,
51-
'info-box--error': this.error
46+
[`info-box--${this.styleType}`]: this.styleType
5247
};
5348
}
5449
}

src/components/molecules/Upload.vue

-7
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export default {
6565
type: String,
6666
default: 'Max. video length: %length% seconds.'
6767
},
68-
androidExperimentalText: {
69-
type: String,
70-
default: 'Android support is experimental. In case of problems, switch to another device.'
71-
},
7268
errorMessages: {
7369
type: Object,
7470
default () {
@@ -132,9 +128,6 @@ export default {
132128
const text = [
133129
this.maxLengthText.replace('%length%', this.getMaxLength())
134130
];
135-
if (this.$isDeviceAndroid()) {
136-
text.unshift(this.androidExperimentalText);
137-
}
138131
this.infoText = text.join('<br>');
139132
},
140133

src/components/molecules/UploadModifier.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ export default {
139139
default () {
140140
return {
141141
[ERROR]: {
142-
error: true,
143-
styleType: null,
142+
styleType: 'error',
144143
headline: 'Conversion failed.',
145144
text: 'Sorry! Please, try another browser or device.',
146145
foot: null

src/components/organisms/AudioModifier.vue

+46-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<template>
22
<div class="organism-audio-modifier">
3+
<transition name="fade" mode="out-in">
4+
<lost-container v-if="isAndroid" class="audio-modifier__device-notification" direction="column">
5+
<info-box v-bind="deviceNotification" style-type="error" />
6+
</lost-container>
7+
</transition>
38
<upload-modifier class="audio-modifier__upload" v-bind="uploadModifier" @reset="onReset" @ready="onReady" @info="onChangeInfo" />
49
<lost-container v-if="!complete" class="audio-modifier" direction="column">
510
<transition name="fade" mode="out-in">
@@ -15,14 +20,16 @@ import UploadModifier from '@/components/molecules/UploadModifier';
1520
import InfoList from '@/components/molecules/InfoList';
1621
import InfoSlider from '@/components/molecules/InfoSlider';
1722
import { CONVERSION_COMPLETE, CONVERSION_START } from '@/classes/FFMPEGWorker';
18-
import LostContainer from '../layouts/LostContainer';
23+
import LostContainer from '@/components/layouts/LostContainer';
24+
import InfoBox from '@/components/atoms/InfoBox';
1925
2026
export default {
2127
components: {
2228
LostContainer,
2329
UploadModifier,
2430
InfoList,
25-
InfoSlider
31+
InfoSlider,
32+
InfoBox
2633
},
2734
2835
props: {
@@ -48,11 +55,25 @@ export default {
4855
4956
data () {
5057
return {
58+
isAndroid: false,
5159
complete: false,
5260
processing: false
5361
};
5462
},
5563
64+
computed: {
65+
deviceNotification () {
66+
return {
67+
headline: null,
68+
text: 'Android support is experimental. <br>In case of problems, switch to another device.'
69+
};
70+
}
71+
},
72+
73+
mounted () {
74+
this.isAndroid = this.$isDeviceAndroid();
75+
},
76+
5677
methods: {
5778
onChangeInfo (info) {
5879
switch (info) {
@@ -75,13 +96,35 @@ export default {
7596
</script>
7697

7798
<style lang="postcss" scoped>
78-
div {
99+
.organism-audio-modifier {
79100
& ul {
80101
padding: 0;
81102
margin: 0;
82103
list-style: none;
83104
}
84105
106+
& .audio-modifier__device-notification {
107+
lost-column: 12/12;
108+
lost-offset: 0/12;
109+
margin-top: -20px;
110+
margin-bottom: 40px;
111+
112+
@media (--sm) {
113+
lost-column: 10/12;
114+
lost-offset: 1/12;
115+
}
116+
117+
@media (--md) {
118+
lost-column: 8/12;
119+
lost-offset: 2/12;
120+
}
121+
122+
@media (--lg) {
123+
lost-column: 6/12;
124+
lost-offset: 3/12;
125+
}
126+
}
127+
85128
& .audio-modifier__upload + * {
86129
margin-top: calc(40 / 320 * 100vw);
87130

src/modules/device-detection/plugin.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ export function isSupportedBrowser (browserSupport) {
55

66
export default (context, inject) => {
77
inject('isDeviceIos', () => isSupportedBrowser(<%= options.detections.ios %>));
8-
inject('isBrowserSafari', () => navigator.userAgent.toLowerCase().indexOf('safari/') > -1 && navigator.userAgent.toLowerCase().indexOf('fxios/') < 0);
9-
10-
// inject('isDeviceAndroid', () => isSupportedBrowser(<%= options.detections.android %>));
8+
inject('isBrowserSafari', () => isBrowserSafari());
119
inject('isDeviceAndroid', () => global.navigator.userAgent.toLocaleLowerCase().includes('android'));
1210
}
11+
12+
function isBrowserSafari(){
13+
const userAgent = navigator.userAgent.toLowerCase();
14+
return userAgent.indexOf('safari/') > -1 &&
15+
userAgent.indexOf('fxios/') < 0 &&
16+
userAgent.indexOf('edgios/') < 0 &&
17+
userAgent.indexOf('crios/') < 0 &&
18+
userAgent.indexOf('opios/') < 0 &&
19+
userAgent.indexOf('puffin/') < 0
20+
}
21+

0 commit comments

Comments
 (0)