Added debug screen, fixed ios icon size

This commit is contained in:
keplyx 2019-08-26 12:49:26 +02:00
parent c8bab93868
commit 528867ab3c
9 changed files with 196 additions and 35 deletions

View file

@ -10,7 +10,7 @@
"android", "android",
"web" "web"
], ],
"version": "0.0.14", "version": "0.0.15",
"orientation": "portrait", "orientation": "portrait",
"primaryColor": "#be1522", "primaryColor": "#be1522",
"icon": "./assets/android.icon.png", "icon": "./assets/android.icon.png",
@ -36,7 +36,7 @@
}, },
"android": { "android": {
"package": "fr.amicaleinsat.application", "package": "fr.amicaleinsat.application",
"versionCode": 2, "versionCode": 3,
"icon": "./assets/android.icon.png", "icon": "./assets/android.icon.png",
"adaptiveIcon": { "adaptiveIcon": {
"foregroundImage": "./assets/android.adaptive-icon.png", "foregroundImage": "./assets/android.adaptive-icon.png",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View file

@ -9,6 +9,7 @@ import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen';
import ProxiwashAboutScreen from '../screens/ProxiwashAboutScreen'; import ProxiwashAboutScreen from '../screens/ProxiwashAboutScreen';
import ProximoAboutScreen from '../screens/Proximo/ProximoAboutScreen'; import ProximoAboutScreen from '../screens/Proximo/ProximoAboutScreen';
import SelfMenuScreen from '../screens/SelfMenuScreen'; import SelfMenuScreen from '../screens/SelfMenuScreen';
import DebugScreen from '../screens/DebugScreen';
import {fromRight} from "react-navigation-transitions"; import {fromRight} from "react-navigation-transitions";
/** /**
@ -25,6 +26,7 @@ export default createAppContainer(
SelfMenuScreen: {screen: SelfMenuScreen}, SelfMenuScreen: {screen: SelfMenuScreen},
ProxiwashAboutScreen: {screen: ProxiwashAboutScreen}, ProxiwashAboutScreen: {screen: ProxiwashAboutScreen},
ProximoAboutScreen: {screen: ProximoAboutScreen}, ProximoAboutScreen: {screen: ProximoAboutScreen},
DebugScreen: {screen: DebugScreen},
}, },
{ {
initialRouteName: "Main", initialRouteName: "Main",

View file

@ -1,13 +1,14 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {Alert, FlatList, Linking, Platform} from 'react-native'; import {FlatList, Linking, Platform, View} from 'react-native';
import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail} from 'native-base'; import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail} from 'native-base';
import CustomHeader from "../../components/CustomHeader"; import CustomHeader from "../../components/CustomHeader";
import i18n from "i18n-js"; import i18n from "i18n-js";
import appJson from '../../app'; import appJson from '../../app';
import packageJson from '../../package'; import packageJson from '../../package';
import CustomMaterialIcon from "../../components/CustomMaterialIcon"; import CustomMaterialIcon from "../../components/CustomMaterialIcon";
import AsyncStorageManager from "../../utils/AsyncStorageManager";
const links = { const links = {
appstore: 'https://qwant.com', appstore: 'https://qwant.com',
@ -27,6 +28,10 @@ type Props = {
navigation: Object, navigation: Object,
}; };
type State = {
isDebugUnlocked: boolean,
};
/** /**
* Opens a link in the device's browser * Opens a link in the device's browser
* @param link The link to open * @param link The link to open
@ -38,7 +43,13 @@ function openWebLink(link) {
/** /**
* Class defining an about screen. This screen shows the user information about the app and it's author. * Class defining an about screen. This screen shows the user information about the app and it's author.
*/ */
export default class AboutScreen extends React.Component<Props> { export default class AboutScreen extends React.Component<Props, State> {
debugTapCounter = 0;
state = {
isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
};
/** /**
* Data to be displayed in the app card * Data to be displayed in the app card
@ -80,6 +91,13 @@ export default class AboutScreen extends React.Component<Props> {
text: i18n.t('aboutScreen.license'), text: i18n.t('aboutScreen.license'),
showChevron: true showChevron: true
}, },
{
onPressCallback: () => this.props.navigation.navigate('DebugScreen'),
icon: 'bug-check',
text: i18n.t('aboutScreen.debug'),
showChevron: true,
showOnlyDebug: true
},
]; ];
/** /**
@ -87,7 +105,7 @@ export default class AboutScreen extends React.Component<Props> {
*/ */
authorData: Array<Object> = [ authorData: Array<Object> = [
{ {
onPressCallback: () => Alert.alert('Coucou', 'Whaou'), onPressCallback: () => this.tryUnlockDebugMode(),
icon: 'account-circle', icon: 'account-circle',
text: 'Arnaud VERGNET', text: 'Arnaud VERGNET',
showChevron: false showChevron: false
@ -137,9 +155,12 @@ export default class AboutScreen extends React.Component<Props> {
* @param icon The icon name to use from MaterialCommunityIcons * @param icon The icon name to use from MaterialCommunityIcons
* @param text The text to show * @param text The text to show
* @param showChevron Whether to show a chevron indicating this button will change screen * @param showChevron Whether to show a chevron indicating this button will change screen
* @param showOnlyInDebug Should we show te current item only in debug mode?
* @returns {React.Node} * @returns {React.Node}
*/ */
static getCardItem(onPressCallback: Function, icon: string, text: string, showChevron: boolean) { getCardItem(onPressCallback: Function, icon: string, text: string, showChevron: boolean, showOnlyInDebug: boolean) {
let shouldShow = !showOnlyInDebug || (showOnlyInDebug && this.state.isDebugUnlocked);
if (shouldShow) {
return ( return (
<CardItem button <CardItem button
onPress={onPressCallback}> onPress={onPressCallback}>
@ -157,6 +178,25 @@ export default class AboutScreen extends React.Component<Props> {
} }
</CardItem>) </CardItem>)
; ;
} else {
return <View/>
}
}
tryUnlockDebugMode() {
this.debugTapCounter = this.debugTapCounter + 1;
console.log(this.debugTapCounter);
if (this.debugTapCounter >= 4) {
this.unlockDebugMode();
}
}
unlockDebugMode() {
console.log('unlocked');
this.setState({isDebugUnlocked: true});
let key = AsyncStorageManager.getInstance().preferences.debugUnlocked.key;
AsyncStorageManager.getInstance().savePref(key, '1');
} }
render() { render() {
@ -168,9 +208,9 @@ export default class AboutScreen extends React.Component<Props> {
<Card> <Card>
<CardItem> <CardItem>
<Left> <Left>
<Thumbnail square source={require('../../assets/amicale.png')}/> <Thumbnail square source={require('../../assets/icon.png')}/>
<Body> <Body>
<H1>Amicale INSA Toulouse</H1> <H1>CAMPUS - Amicale INSAT</H1>
<Text note> <Text note>
v.{appJson.expo.version} v.{appJson.expo.version}
</Text> </Text>
@ -179,9 +219,10 @@ export default class AboutScreen extends React.Component<Props> {
</CardItem> </CardItem>
<FlatList <FlatList
data={this.appData} data={this.appData}
extraData={this.state}
keyExtractor={(item) => item.icon} keyExtractor={(item) => item.icon}
renderItem={({item}) => renderItem={({item}) =>
AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron) this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
} }
/> />
</Card> </Card>
@ -192,9 +233,10 @@ export default class AboutScreen extends React.Component<Props> {
</CardItem> </CardItem>
<FlatList <FlatList
data={this.authorData} data={this.authorData}
extraData={this.state}
keyExtractor={(item) => item.icon} keyExtractor={(item) => item.icon}
renderItem={({item}) => renderItem={({item}) =>
AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron) this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
} }
/> />
</Card> </Card>
@ -205,9 +247,10 @@ export default class AboutScreen extends React.Component<Props> {
</CardItem> </CardItem>
<FlatList <FlatList
data={this.technoData} data={this.technoData}
extraData={this.state}
keyExtractor={(item) => item.icon} keyExtractor={(item) => item.icon}
renderItem={({item}) => renderItem={({item}) =>
AboutScreen.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron) this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
} }
/> />
</Card> </Card>

99
screens/DebugScreen.js Normal file
View file

@ -0,0 +1,99 @@
// @flow
import * as React from 'react';
import {Body, Card, CardItem, Container, Content, Left, List, ListItem, Right, Text,} from "native-base";
import CustomHeader from "../components/CustomHeader";
import ThemeManager from '../utils/ThemeManager';
import i18n from "i18n-js";
import CustomMaterialIcon from "../components/CustomMaterialIcon";
import Touchable from "react-native-platform-touchable";
import {Alert, Platform, Clipboard} from "react-native";
import AsyncStorageManager from "../utils/AsyncStorageManager";
import NotificationsManager from "../utils/NotificationsManager";
type Props = {
navigation: Object,
};
/**
* Class defining the Debug screen. This screen allows the user to get detailed information on the app/device.
*/
export default class DebugScreen extends React.Component<Props> {
alertCurrentExpoToken() {
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
console.log(token);
Alert.alert(
'Expo Token',
token,
[
{text: 'Copy', onPress: () => Clipboard.setString(token)},
{text: 'OK'}
]
);
}
async forceExpoTokenUpdate() {
await NotificationsManager.forceExpoTokenUpdate();
this.alertCurrentExpoToken();
}
static getGeneralItem(onPressCallback: Function, icon: string, title: string, subtitle: string) {
return (
<CardItem
button
onPress={onPressCallback}
>
<Left>
<CustomMaterialIcon icon={icon}/>
</Left>
<Body>
<Text>
{title}
</Text>
<Text note>
{subtitle}
</Text>
</Body>
<Right/>
</CardItem>
);
}
getRightButton() {
return (
<Touchable
style={{padding: 6}}
onPress={() => this.props.navigation.navigate('AboutScreen')}>
<CustomMaterialIcon
color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
icon="information"/>
</Touchable>
);
}
render() {
const nav = this.props.navigation;
return (
<Container>
<CustomHeader navigation={nav} title={i18n.t('screens.debug')} hasBackButton={true}
rightButton={this.getRightButton()}/>
<Content padder>
<Card>
<CardItem header>
<Text>
Notifications
</Text>
</CardItem>
<List>
{DebugScreen.getGeneralItem(() => this.alertCurrentExpoToken(), 'bell', 'Get current Expo Token', '')}
{DebugScreen.getGeneralItem(() => this.forceExpoTokenUpdate(),'bell-ring', 'Force Expo token update', '')}
</List>
</Card>
</Content>
</Container>
);
}
}

View file

@ -6,7 +6,8 @@
"proximo": "Proximo", "proximo": "Proximo",
"menuSelf": "RU Menu", "menuSelf": "RU Menu",
"settings": "Settings", "settings": "Settings",
"about": "About" "about": "About",
"debug": "Debug"
}, },
"intro": { "intro": {
"slide1": { "slide1": {
@ -15,7 +16,7 @@
}, },
"slide2": { "slide2": {
"title": "Stay up to date", "title": "Stay up to date",
"text": "CAMPUS will soon allow you to be aware of any event occuring on the campus, from pancake sales to Enfoiros concerts!" "text": "CAMPUS will soon allow you to be aware of any event occurring on the campus, from pancake sales to Enfoiros concerts!"
}, },
"slide3": { "slide3": {
"title": "Never forget your laundry", "title": "Never forget your laundry",
@ -23,7 +24,7 @@
}, },
"slide4": { "slide4": {
"title": "Proximo", "title": "Proximo",
"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" "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"
}, },
"slide5": { "slide5": {
"title": "Planex", "title": "Planex",
@ -31,7 +32,7 @@
}, },
"slide6": { "slide6": {
"title": "Still in development", "title": "Still in development",
"text": "New features coming soon, do not hesitate to give us feedback to improve the app" "text": "New features are coming soon, do not hesitate to give us feedback to improve the app"
} }
}, },
"settingsScreen": { "settingsScreen": {
@ -66,6 +67,7 @@
"bugs": "Report Bugs", "bugs": "Report Bugs",
"changelog": "Changelog", "changelog": "Changelog",
"license": "License", "license": "License",
"debug": "Debug",
"author": "Author", "author": "Author",
"mail": "Send an email", "mail": "Send an email",
"technologies": "Technologies", "technologies": "Technologies",

View file

@ -6,7 +6,8 @@
"proximo": "Proximo", "proximo": "Proximo",
"menuSelf": "Menu Ru", "menuSelf": "Menu Ru",
"settings": "Paramètres", "settings": "Paramètres",
"about": "À Propos" "about": "À Propos",
"debug": "Debug"
}, },
"intro": { "intro": {
"slide1": { "slide1": {
@ -66,6 +67,7 @@
"bugs": "Rapporter des Bugs", "bugs": "Rapporter des Bugs",
"changelog": "Historique des modifications", "changelog": "Historique des modifications",
"license": "Licence", "license": "Licence",
"debug": "Debug",
"author": "Auteur", "author": "Auteur",
"mail": "Envoyer un mail", "mail": "Envoyer un mail",
"technologies": "Technologies", "technologies": "Technologies",
@ -127,7 +129,7 @@
"states": { "states": {
"finished": "TERMINE", "finished": "TERMINE",
"ready": "DISPONIBLE", "ready": "DISPONIBLE",
"running": "En COURS", "running": "EN COURS",
"broken": "HORS SERVICE", "broken": "HORS SERVICE",
"error": "ERREUR" "error": "ERREUR"
}, },

View file

@ -48,6 +48,11 @@ export default class AsyncStorageManager {
key: 'expoToken', key: 'expoToken',
default: '', default: '',
current: '', current: '',
},
debugUnlocked: {
key: 'debugUnlocked',
default: '0',
current: '',
} }
}; };

View file

@ -95,12 +95,20 @@ export default class NotificationsManager {
static async initExpoToken() { static async initExpoToken() {
let token = AsyncStorageManager.getInstance().preferences.expoToken.current; let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
if (token === '') { if (token === '') {
await NotificationsManager.askPermissions();
let expoToken = await Notifications.getExpoPushTokenAsync(); let expoToken = await Notifications.getExpoPushTokenAsync();
// Save token for instant use later on // Save token for instant use later on
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken); AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
} }
} }
static async forceExpoTokenUpdate() {
await NotificationsManager.askPermissions();
let expoToken = await Notifications.getExpoPushTokenAsync();
// Save token for instant use later on
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
}
static getMachineNotificationWatchlist(callback: Function) { static getMachineNotificationWatchlist(callback: Function) {
let token = AsyncStorageManager.getInstance().preferences.expoToken.current; let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
if (token === '') { if (token === '') {