Browse Source

Added debug screen, fixed ios icon size

keplyx 4 years ago
parent
commit
528867ab3c

+ 2
- 2
app.json View File

10
       "android",
10
       "android",
11
       "web"
11
       "web"
12
     ],
12
     ],
13
-    "version": "0.0.14",
13
+    "version": "0.0.15",
14
     "orientation": "portrait",
14
     "orientation": "portrait",
15
     "primaryColor": "#be1522",
15
     "primaryColor": "#be1522",
16
     "icon": "./assets/android.icon.png",
16
     "icon": "./assets/android.icon.png",
36
     },
36
     },
37
     "android": {
37
     "android": {
38
       "package": "fr.amicaleinsat.application",
38
       "package": "fr.amicaleinsat.application",
39
-      "versionCode": 2,
39
+      "versionCode": 3,
40
       "icon": "./assets/android.icon.png",
40
       "icon": "./assets/android.icon.png",
41
       "adaptiveIcon": {
41
       "adaptiveIcon": {
42
         "foregroundImage": "./assets/android.adaptive-icon.png",
42
         "foregroundImage": "./assets/android.adaptive-icon.png",

BIN
assets/ios.icon.png View File


+ 2
- 0
navigation/AppNavigator.js View File

9
 import ProxiwashAboutScreen from '../screens/ProxiwashAboutScreen';
9
 import ProxiwashAboutScreen from '../screens/ProxiwashAboutScreen';
10
 import ProximoAboutScreen from '../screens/Proximo/ProximoAboutScreen';
10
 import ProximoAboutScreen from '../screens/Proximo/ProximoAboutScreen';
11
 import SelfMenuScreen from '../screens/SelfMenuScreen';
11
 import SelfMenuScreen from '../screens/SelfMenuScreen';
12
+import DebugScreen from '../screens/DebugScreen';
12
 import {fromRight} from "react-navigation-transitions";
13
 import {fromRight} from "react-navigation-transitions";
13
 
14
 
14
 /**
15
 /**
25
             SelfMenuScreen: {screen: SelfMenuScreen},
26
             SelfMenuScreen: {screen: SelfMenuScreen},
26
             ProxiwashAboutScreen: {screen: ProxiwashAboutScreen},
27
             ProxiwashAboutScreen: {screen: ProxiwashAboutScreen},
27
             ProximoAboutScreen: {screen: ProximoAboutScreen},
28
             ProximoAboutScreen: {screen: ProximoAboutScreen},
29
+            DebugScreen: {screen: DebugScreen},
28
         },
30
         },
29
         {
31
         {
30
             initialRouteName: "Main",
32
             initialRouteName: "Main",

+ 69
- 26
screens/About/AboutScreen.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import * as React from 'react';
3
 import * as React from 'react';
4
-import {Alert, FlatList, Linking, Platform} from 'react-native';
4
+import {FlatList, Linking, Platform, View} from 'react-native';
5
 import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail} from 'native-base';
5
 import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail} from 'native-base';
6
 import CustomHeader from "../../components/CustomHeader";
6
 import CustomHeader from "../../components/CustomHeader";
7
 import i18n from "i18n-js";
7
 import i18n from "i18n-js";
8
 import appJson from '../../app';
8
 import appJson from '../../app';
9
 import packageJson from '../../package';
9
 import packageJson from '../../package';
10
 import CustomMaterialIcon from "../../components/CustomMaterialIcon";
10
 import CustomMaterialIcon from "../../components/CustomMaterialIcon";
11
+import AsyncStorageManager from "../../utils/AsyncStorageManager";
11
 
12
 
12
 const links = {
13
 const links = {
13
     appstore: 'https://qwant.com',
14
     appstore: 'https://qwant.com',
27
     navigation: Object,
28
     navigation: Object,
28
 };
29
 };
29
 
30
 
31
+type State = {
32
+    isDebugUnlocked: boolean,
33
+};
34
+
30
 /**
35
 /**
31
  * Opens a link in the device's browser
36
  * Opens a link in the device's browser
32
  * @param link The link to open
37
  * @param link The link to open
38
 /**
43
 /**
39
  * Class defining an about screen. This screen shows the user information about the app and it's author.
44
  * Class defining an about screen. This screen shows the user information about the app and it's author.
40
  */
45
  */
41
-export default class AboutScreen extends React.Component<Props> {
46
+export default class AboutScreen extends React.Component<Props, State> {
47
+
48
+    debugTapCounter = 0;
49
+
50
+    state = {
51
+        isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
52
+    };
42
 
53
 
43
     /**
54
     /**
44
      * Data to be displayed in the app card
55
      * Data to be displayed in the app card
80
             text: i18n.t('aboutScreen.license'),
91
             text: i18n.t('aboutScreen.license'),
81
             showChevron: true
92
             showChevron: true
82
         },
93
         },
94
+        {
95
+            onPressCallback: () => this.props.navigation.navigate('DebugScreen'),
96
+            icon: 'bug-check',
97
+            text: i18n.t('aboutScreen.debug'),
98
+            showChevron: true,
99
+            showOnlyDebug: true
100
+        },
83
     ];
101
     ];
84
 
102
 
85
     /**
103
     /**
87
      */
105
      */
88
     authorData: Array<Object> = [
106
     authorData: Array<Object> = [
89
         {
107
         {
90
-            onPressCallback: () => Alert.alert('Coucou', 'Whaou'),
108
+            onPressCallback: () => this.tryUnlockDebugMode(),
91
             icon: 'account-circle',
109
             icon: 'account-circle',
92
             text: 'Arnaud VERGNET',
110
             text: 'Arnaud VERGNET',
93
             showChevron: false
111
             showChevron: false
137
      * @param icon The icon name to use from MaterialCommunityIcons
155
      * @param icon The icon name to use from MaterialCommunityIcons
138
      * @param text The text to show
156
      * @param text The text to show
139
      * @param showChevron Whether to show a chevron indicating this button will change screen
157
      * @param showChevron Whether to show a chevron indicating this button will change screen
158
+     * @param showOnlyInDebug Should we show te current item only in debug mode?
140
      * @returns {React.Node}
159
      * @returns {React.Node}
141
      */
160
      */
142
-    static getCardItem(onPressCallback: Function, icon: string, text: string, showChevron: boolean) {
143
-        return (
144
-            <CardItem button
145
-                      onPress={onPressCallback}>
146
-                <Left>
147
-                    <CustomMaterialIcon icon={icon}/>
148
-                    <Text>{text}</Text>
149
-                </Left>
150
-                {showChevron ?
151
-                    <Right>
152
-                        <CustomMaterialIcon icon="chevron-right"
153
-                                            fontSize={20}/>
154
-                    </Right>
155
-                    :
156
-                    <Right/>
157
-                }
158
-            </CardItem>)
159
-            ;
161
+    getCardItem(onPressCallback: Function, icon: string, text: string, showChevron: boolean, showOnlyInDebug: boolean) {
162
+        let shouldShow = !showOnlyInDebug || (showOnlyInDebug && this.state.isDebugUnlocked);
163
+        if (shouldShow) {
164
+            return (
165
+                <CardItem button
166
+                          onPress={onPressCallback}>
167
+                    <Left>
168
+                        <CustomMaterialIcon icon={icon}/>
169
+                        <Text>{text}</Text>
170
+                    </Left>
171
+                    {showChevron ?
172
+                        <Right>
173
+                            <CustomMaterialIcon icon="chevron-right"
174
+                                                fontSize={20}/>
175
+                        </Right>
176
+                        :
177
+                        <Right/>
178
+                    }
179
+                </CardItem>)
180
+                ;
181
+        } else {
182
+            return <View/>
183
+        }
184
+
185
+    }
186
+
187
+    tryUnlockDebugMode() {
188
+        this.debugTapCounter = this.debugTapCounter + 1;
189
+        console.log(this.debugTapCounter);
190
+        if (this.debugTapCounter >= 4) {
191
+            this.unlockDebugMode();
192
+        }
193
+    }
194
+
195
+    unlockDebugMode() {
196
+        console.log('unlocked');
197
+        this.setState({isDebugUnlocked: true});
198
+        let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
199
+        AsyncStorageManager.getInstance().savePref(key, '1');
160
     }
200
     }
161
 
201
 
162
     render() {
202
     render() {
168
                     <Card>
208
                     <Card>
169
                         <CardItem>
209
                         <CardItem>
170
                             <Left>
210
                             <Left>
171
-                                <Thumbnail square source={require('../../assets/amicale.png')}/>
211
+                                <Thumbnail square source={require('../../assets/icon.png')}/>
172
                                 <Body>
212
                                 <Body>
173
-                                    <H1>Amicale INSA Toulouse</H1>
213
+                                    <H1>CAMPUS - Amicale INSAT</H1>
174
                                     <Text note>
214
                                     <Text note>
175
                                         v.{appJson.expo.version}
215
                                         v.{appJson.expo.version}
176
                                     </Text>
216
                                     </Text>
179
                         </CardItem>
219
                         </CardItem>
180
                         <FlatList
220
                         <FlatList
181
                             data={this.appData}
221
                             data={this.appData}
222
+                            extraData={this.state}
182
                             keyExtractor={(item) => item.icon}
223
                             keyExtractor={(item) => item.icon}
183
                             renderItem={({item}) =>
224
                             renderItem={({item}) =>
184
-                                AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron)
225
+                                this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
185
                             }
226
                             }
186
                         />
227
                         />
187
                     </Card>
228
                     </Card>
192
                         </CardItem>
233
                         </CardItem>
193
                         <FlatList
234
                         <FlatList
194
                             data={this.authorData}
235
                             data={this.authorData}
236
+                            extraData={this.state}
195
                             keyExtractor={(item) => item.icon}
237
                             keyExtractor={(item) => item.icon}
196
                             renderItem={({item}) =>
238
                             renderItem={({item}) =>
197
-                                AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron)
239
+                                this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
198
                             }
240
                             }
199
                         />
241
                         />
200
                     </Card>
242
                     </Card>
205
                         </CardItem>
247
                         </CardItem>
206
                         <FlatList
248
                         <FlatList
207
                             data={this.technoData}
249
                             data={this.technoData}
250
+                            extraData={this.state}
208
                             keyExtractor={(item) => item.icon}
251
                             keyExtractor={(item) => item.icon}
209
                             renderItem={({item}) =>
252
                             renderItem={({item}) =>
210
-                                AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron)
253
+                                this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
211
                             }
254
                             }
212
                         />
255
                         />
213
                     </Card>
256
                     </Card>

+ 99
- 0
screens/DebugScreen.js View File

1
+// @flow
2
+
3
+import * as React from 'react';
4
+import {Body, Card, CardItem, Container, Content, Left, List, ListItem, Right, Text,} from "native-base";
5
+import CustomHeader from "../components/CustomHeader";
6
+import ThemeManager from '../utils/ThemeManager';
7
+import i18n from "i18n-js";
8
+import CustomMaterialIcon from "../components/CustomMaterialIcon";
9
+import Touchable from "react-native-platform-touchable";
10
+import {Alert, Platform, Clipboard} from "react-native";
11
+import AsyncStorageManager from "../utils/AsyncStorageManager";
12
+import NotificationsManager from "../utils/NotificationsManager";
13
+
14
+type Props = {
15
+    navigation: Object,
16
+};
17
+
18
+/**
19
+ * Class defining the Debug screen. This screen allows the user to get detailed information on the app/device.
20
+ */
21
+export default class DebugScreen extends React.Component<Props> {
22
+
23
+    alertCurrentExpoToken() {
24
+        let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
25
+        console.log(token);
26
+        Alert.alert(
27
+            'Expo Token',
28
+            token,
29
+            [
30
+                {text: 'Copy', onPress: () => Clipboard.setString(token)},
31
+                {text: 'OK'}
32
+            ]
33
+        );
34
+    }
35
+
36
+    async forceExpoTokenUpdate() {
37
+        await NotificationsManager.forceExpoTokenUpdate();
38
+        this.alertCurrentExpoToken();
39
+    }
40
+
41
+
42
+    static getGeneralItem(onPressCallback: Function, icon: string, title: string, subtitle: string) {
43
+        return (
44
+            <CardItem
45
+                button
46
+                onPress={onPressCallback}
47
+            >
48
+                <Left>
49
+                    <CustomMaterialIcon icon={icon}/>
50
+                </Left>
51
+                <Body>
52
+                    <Text>
53
+                        {title}
54
+                    </Text>
55
+                    <Text note>
56
+                        {subtitle}
57
+                    </Text>
58
+                </Body>
59
+                <Right/>
60
+            </CardItem>
61
+        );
62
+    }
63
+
64
+    getRightButton() {
65
+        return (
66
+            <Touchable
67
+                style={{padding: 6}}
68
+                onPress={() => this.props.navigation.navigate('AboutScreen')}>
69
+                <CustomMaterialIcon
70
+                    color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
71
+                    icon="information"/>
72
+            </Touchable>
73
+        );
74
+    }
75
+
76
+    render() {
77
+        const nav = this.props.navigation;
78
+        return (
79
+            <Container>
80
+                <CustomHeader navigation={nav} title={i18n.t('screens.debug')} hasBackButton={true}
81
+                              rightButton={this.getRightButton()}/>
82
+                <Content padder>
83
+                    <Card>
84
+                        <CardItem header>
85
+                            <Text>
86
+                                Notifications
87
+                            </Text>
88
+                        </CardItem>
89
+                        <List>
90
+                            {DebugScreen.getGeneralItem(() => this.alertCurrentExpoToken(), 'bell', 'Get current Expo Token', '')}
91
+                            {DebugScreen.getGeneralItem(() => this.forceExpoTokenUpdate(),'bell-ring', 'Force Expo token update', '')}
92
+                        </List>
93
+                    </Card>
94
+                </Content>
95
+            </Container>
96
+
97
+        );
98
+    }
99
+}

+ 7
- 5
translations/en.json View File

6
     "proximo": "Proximo",
6
     "proximo": "Proximo",
7
     "menuSelf": "RU Menu",
7
     "menuSelf": "RU Menu",
8
     "settings": "Settings",
8
     "settings": "Settings",
9
-    "about": "About"
9
+    "about": "About",
10
+    "debug": "Debug"
10
   },
11
   },
11
   "intro": {
12
   "intro": {
12
     "slide1": {
13
     "slide1": {
15
     },
16
     },
16
     "slide2": {
17
     "slide2": {
17
       "title": "Stay up to date",
18
       "title": "Stay up to date",
18
-      "text": "CAMPUS will soon allow you to be aware of any event occuring on the campus, from pancake sales to Enfoiros concerts!"
19
+      "text": "CAMPUS will soon allow you to be aware of any event occurring on the campus, from pancake sales to Enfoiros concerts!"
19
     },
20
     },
20
     "slide3": {
21
     "slide3": {
21
       "title": "Never forget your laundry",
22
       "title": "Never forget your laundry",
22
-      "text": "CAMPUS will inform you on the availability of washing machines and will remind you just before yours finishes !"
23
+      "text": "CAMPUS will inform you on the availability of washing machines and will remind you just before yours finishes!"
23
     },
24
     },
24
     "slide4": {
25
     "slide4": {
25
       "title": "Proximo",
26
       "title": "Proximo",
26
-      "text": "Are you short on pasta? Or you maybe you feel a little peckish, then lookup the stock for your insa shop in real time"
27
+      "text": "Are you short on pasta? Or you maybe you feel a little peckish, then look up your INSA shop's stock in real time"
27
     },
28
     },
28
     "slide5": {
29
     "slide5": {
29
       "title": "Planex",
30
       "title": "Planex",
31
     },
32
     },
32
     "slide6": {
33
     "slide6": {
33
       "title": "Still in development",
34
       "title": "Still in development",
34
-      "text": "New features coming soon, do not hesitate to give us feedback to improve the app"
35
+      "text": "New features are coming soon, do not hesitate to give us feedback to improve the app"
35
     }
36
     }
36
   },
37
   },
37
   "settingsScreen": {
38
   "settingsScreen": {
66
     "bugs": "Report Bugs",
67
     "bugs": "Report Bugs",
67
     "changelog": "Changelog",
68
     "changelog": "Changelog",
68
     "license": "License",
69
     "license": "License",
70
+    "debug": "Debug",
69
     "author": "Author",
71
     "author": "Author",
70
     "mail": "Send an email",
72
     "mail": "Send an email",
71
     "technologies": "Technologies",
73
     "technologies": "Technologies",

+ 4
- 2
translations/fr.json View File

6
     "proximo": "Proximo",
6
     "proximo": "Proximo",
7
     "menuSelf": "Menu Ru",
7
     "menuSelf": "Menu Ru",
8
     "settings": "Paramètres",
8
     "settings": "Paramètres",
9
-    "about": "À Propos"
9
+    "about": "À Propos",
10
+    "debug": "Debug"
10
   },
11
   },
11
   "intro": {
12
   "intro": {
12
     "slide1": {
13
     "slide1": {
66
     "bugs": "Rapporter des Bugs",
67
     "bugs": "Rapporter des Bugs",
67
     "changelog": "Historique des modifications",
68
     "changelog": "Historique des modifications",
68
     "license": "Licence",
69
     "license": "Licence",
70
+    "debug": "Debug",
69
     "author": "Auteur",
71
     "author": "Auteur",
70
     "mail": "Envoyer un mail",
72
     "mail": "Envoyer un mail",
71
     "technologies": "Technologies",
73
     "technologies": "Technologies",
127
     "states": {
129
     "states": {
128
       "finished": "TERMINE",
130
       "finished": "TERMINE",
129
       "ready": "DISPONIBLE",
131
       "ready": "DISPONIBLE",
130
-      "running": "En COURS",
132
+      "running": "EN COURS",
131
       "broken": "HORS SERVICE",
133
       "broken": "HORS SERVICE",
132
       "error": "ERREUR"
134
       "error": "ERREUR"
133
     },
135
     },

+ 5
- 0
utils/AsyncStorageManager.js View File

48
             key: 'expoToken',
48
             key: 'expoToken',
49
             default: '',
49
             default: '',
50
             current: '',
50
             current: '',
51
+        },
52
+        debugUnlocked: {
53
+            key: 'debugUnlocked',
54
+            default: '0',
55
+            current: '',
51
         }
56
         }
52
     };
57
     };
53
 
58
 

+ 8
- 0
utils/NotificationsManager.js View File

95
     static async initExpoToken() {
95
     static async initExpoToken() {
96
         let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
96
         let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
97
         if (token === '') {
97
         if (token === '') {
98
+            await NotificationsManager.askPermissions();
98
             let expoToken = await Notifications.getExpoPushTokenAsync();
99
             let expoToken = await Notifications.getExpoPushTokenAsync();
99
             // Save token for instant use later on
100
             // Save token for instant use later on
100
             AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
101
             AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
101
         }
102
         }
102
     }
103
     }
103
 
104
 
105
+    static async forceExpoTokenUpdate() {
106
+        await NotificationsManager.askPermissions();
107
+        let expoToken = await Notifications.getExpoPushTokenAsync();
108
+        // Save token for instant use later on
109
+        AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
110
+    }
111
+
104
     static getMachineNotificationWatchlist(callback: Function) {
112
     static getMachineNotificationWatchlist(callback: Function) {
105
         let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
113
         let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
106
         if (token === '') {
114
         if (token === '') {

Loading…
Cancel
Save