Skip to content

Commit 09fb4ed

Browse files
authored
Merge pull request taskrabbit#32 from taskrabbit/android
[WIP] Android
2 parents 5a47ea2 + f175978 commit 09fb4ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1431
-102
lines changed

.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

.flowconfig

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,58 @@
11
[ignore]
22

33
# We fork some components by platform.
4-
.*/*.web.js
54
.*/*.android.js
65

7-
# Some modules have their own node_modules with overlap
8-
.*/node_modules/node-haste/.*
6+
# Ignore templates with `@flow` in header
7+
.*/local-cli/generator.*
98

10-
# Ugh
11-
.*/node_modules/babel.*
12-
.*/node_modules/babylon.*
13-
.*/node_modules/invariant.*
9+
# Ignore malformed json
10+
.*/node_modules/y18n/test/.*\.json
1411

15-
# Ignore react and fbjs where there are overlaps, but don't ignore
16-
# anything that react-native relies on
17-
.*/node_modules/fbjs-haste/.*/__tests__/.*
18-
.*/node_modules/fbjs-haste/__forks__/Map.js
19-
.*/node_modules/fbjs-haste/__forks__/Promise.js
20-
.*/node_modules/fbjs-haste/__forks__/fetch.js
21-
.*/node_modules/fbjs-haste/core/ExecutionEnvironment.js
22-
.*/node_modules/fbjs-haste/core/isEmpty.js
23-
.*/node_modules/fbjs-haste/crypto/crc32.js
24-
.*/node_modules/fbjs-haste/stubs/ErrorUtils.js
25-
.*/node_modules/react-haste/React.js
26-
.*/node_modules/react-haste/renderers/dom/ReactDOM.js
27-
.*/node_modules/react-haste/renderers/shared/event/eventPlugins/ResponderEventPlugin.js
12+
# Ignore the website subdir
13+
<PROJECT_ROOT>/website/.*
2814

29-
# Ignore commoner tests
30-
.*/node_modules/commoner/test/.*
15+
# Ignore BUCK generated dirs
16+
<PROJECT_ROOT>/\.buckd/
3117

32-
# See https://github.com/facebook/flow/issues/442
33-
.*/react-tools/node_modules/commoner/lib/reader.js
18+
# Ignore unexpected extra @providesModule
19+
.*/node_modules/commoner/test/source/widget/share.js
3420

35-
# Ignore jest
36-
.*/node_modules/jest-cli/.*
37-
38-
# Ignore Website
39-
.*/website/.*
21+
# Ignore duplicate module providers
22+
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
23+
.*/Libraries/react-native/React.js
24+
.*/Libraries/react-native/ReactNative.js
25+
.*/node_modules/jest-runtime/build/__tests__/.*
4026

4127
[include]
4228

4329
[libs]
4430
node_modules/react-native/Libraries/react-native/react-native-interface.js
31+
node_modules/react-native/flow
32+
flow/
4533

4634
[options]
4735
module.system=haste
4836

37+
esproposal.class_static_fields=enable
38+
esproposal.class_instance_fields=enable
39+
40+
experimental.strict_type_args=true
41+
4942
munge_underscores=true
5043

5144
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
52-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
45+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
5346

5447
suppress_type=$FlowIssue
5548
suppress_type=$FlowFixMe
5649
suppress_type=$FixMe
5750

58-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-8]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
59-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-8]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(30\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(30\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
6053
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
6154

55+
unsafe.enable_getters_and_setters=true
56+
6257
[version]
63-
0.18.1
58+
^0.30.0

App/Components/Button.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const Button = React.createClass({
4848
<Text
4949
key={index}
5050
allowFontScaling={false}
51-
style={[{flex: 0, paddingHorizontal: 5, textAlign: 'center'}, styles.text, disabledStateStyle, this._stylesFromType('text'), this.props.textStyle]}
51+
style={[{flex: 0, marginHorizontal: 5, textAlign: 'center'}, styles.text, disabledStateStyle, this._stylesFromType('text'), this.props.textStyle]}
5252
>
5353
{children}
5454
</Text>

App/Components/SimpleListItem.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ var styles = StyleSheet.create({
8585
backgroundColor: 'white'
8686
},
8787
row: {
88-
flex: 1,
8988
flexDirection: 'row',
9089
alignItems: 'center',
9190
padding:20

App/Components/TextInput.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,49 @@ import React from 'react';
22

33
import {
44
PixelRatio,
5-
TextInput,
65
StyleSheet,
6+
TextInput,
77
} from 'react-native';
88

99
import cssVar from '../Lib/cssVar';
1010

11-
var _TextInput = React.createClass({
12-
propTypes: TextInput.propTypes,
11+
class _TextInput extends React.Component {
12+
constructor(props) {
13+
super(props);
14+
}
15+
16+
setNativeProps(...args) {
17+
this.refs.input.setNativeProps(...args);
18+
}
19+
20+
blur() {
21+
this.refs.input.blur();
22+
}
1323

1424
focus() {
1525
this.refs.input.focus();
16-
},
17-
18-
setNativeProps() {
19-
var input = this.refs.input;
20-
input.setNativeProps.apply(input, arguments);
21-
},
26+
}
2227

2328
render() {
2429
return (
2530
<TextInput
31+
ref='input'
2632
{...this.props}
27-
ref="input"
28-
style={[styles.input, this.props.style || {}]}
33+
style={[styles.input, this.props.style]}
2934
/>
3035
);
3136
}
32-
})
37+
}
3338

34-
var styles = StyleSheet.create({
39+
const styles = StyleSheet.create({
3540
input: {
3641
borderWidth: 1 / PixelRatio.get(),
3742
borderColor: cssVar('gray50'),
3843
padding: 10,
3944
fontFamily: cssVar('fontRegular'),
4045
color: cssVar('gray90'),
41-
fontSize: 8 // make it small to know it's not set
42-
}
46+
fontSize: 8, // make it small to know it's not set
47+
},
4348
});
4449

4550
export default _TextInput;

App/Mixins/AuthHelper.js

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,32 @@ var AuthHelper = {
7979
return (
8080
<View style={styles.container}>
8181
<View style={styles.flex} />
82-
<TextInput ref="username"
83-
placeholder={i18n.t('username')}
84-
keyboardType="default"
85-
style={[styles.input, styles.username]}
86-
enablesReturnKeyAutomatically={true}
87-
returnKeyType='next'
88-
onChange={(event) => this.state.username = event.nativeEvent.text }
89-
onSubmitEditing={() => this.refs.password.focus() }
82+
<View style={styles.inputContainer}>
83+
<TextInput ref="username"
84+
placeholder={i18n.t('username')}
85+
keyboardType="default"
86+
style={[styles.input, styles.username]}
87+
enablesReturnKeyAutomatically={true}
88+
autoCapitalize='none'
89+
autoCorrect={false}
90+
returnKeyType='next'
91+
onChange={(event) => this.state.username = event.nativeEvent.text }
92+
onSubmitEditing={() => this.refs.password.focus() }
93+
/>
94+
</View>
95+
<View style={styles.inputContainer}>
96+
<TextInput ref="password"
97+
placeholder={i18n.t('password')}
98+
secureTextEntry={true}
99+
autoCorrect={false}
100+
keyboardType="default"
101+
style={[styles.input, styles.password]}
102+
enablesReturnKeyAutomatically={true}
103+
returnKeyType='done'
104+
onChange={(event) => this.state.password = event.nativeEvent.text }
105+
onSubmitEditing={this.onAuthButton}
90106
/>
91-
<TextInput ref="password"
92-
placeholder={i18n.t('password')}
93-
password={true}
94-
autoCorrect={false}
95-
keyboardType="default"
96-
style={[styles.input, styles.password]}
97-
enablesReturnKeyAutomatically={true}
98-
returnKeyType='done'
99-
onChange={(event) => this.state.password = event.nativeEvent.text }
100-
onSubmitEditing={this.onAuthButton}
101-
/>
107+
</View>
102108
<Button type='blue' onPress={this.onAuthButton}>
103109
{this.getButtonText()}
104110
</Button>
@@ -153,8 +159,12 @@ var styles = StyleSheet.create({
153159
fontSize: 13,
154160
height: 50,
155161
padding: 10,
162+
flex: 1,
156163
marginHorizontal: 30
157164
},
165+
inputContainer: {
166+
flexDirection: 'row'
167+
},
158168
bottom: {
159169
flexDirection: 'row'
160170
},

App/Mixins/KeyboardListener.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ var KeyboardListener = {
1616
return this.state.keyboardSpace > 0;
1717
},
1818

19-
isKeyboardVisible: function() {
20-
return this.state.keyboardSpace > 0;
21-
},
22-
2319
updateKeyboardSpace: function(e) {
2420
if (this.isMounted() && e && e.endCoordinates) {
2521
this.setState({keyboardSpace: e.endCoordinates.height});

App/Navigation/NavigationBar.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88

99
import cssVar from '../Lib/cssVar';
1010

11+
import Back from '../Platform/Back';
1112
import NavigatorNavigationBarStyles from '../Platform/NavigatorNavigationBarStyles';
1213
import NavigationBarRouteMapper from '../Navigation/NavigationBarRouteMapper';
1314

@@ -128,6 +129,10 @@ var NavigationBar = {
128129
);
129130
},
130131

132+
componentDidMount: function() {
133+
Back.setNavigator(this.refs.navigator);
134+
},
135+
131136
render: function() {
132137
return (
133138
<View style={styles.appContainer}>

App/Platform/Alert.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

App/Platform/Back.android.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
3+
import {
4+
BackAndroid,
5+
} from 'react-native';
6+
7+
import AppActions from '../Actions/AppActions';
8+
// import DrawerStore from '../Stores/DrawerStore';
9+
10+
const Back = {
11+
setNavigator(navigator) {
12+
BackAndroid.addEventListener('hardwareBackPress', () => {
13+
// if (DrawerStore.get().open === true) {
14+
// AppActions.toggleDrawer();
15+
// return true;
16+
// }
17+
if (navigator && navigator.getCurrentRoutes().length > 1) {
18+
AppActions.goBack(navigator);
19+
return true;
20+
}
21+
return false;
22+
});
23+
},
24+
};
25+
26+
export default Back;

App/Platform/Keychain.android.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
3+
import LocalKeyStore from '../Stores/LocalKeyStore';
4+
5+
const KEYCHAIN_STORAGE_KEY = 'KEYCHAIN';
6+
7+
var KeyChain = {
8+
setGenericPassword(username, password, service) {
9+
return new Promise((resolve) => {
10+
LocalKeyStore.setKey(this.getStorageKey(service), {username, password}, (error) => {
11+
resolve();
12+
});
13+
});
14+
},
15+
16+
getGenericPassword(service) {
17+
return new Promise((resolve) => {
18+
LocalKeyStore.getKey(this.getStorageKey(service), (error, value) => {
19+
resolve(value);
20+
});
21+
});
22+
},
23+
24+
resetGenericPassword(service) {
25+
return new Promise((resolve) => {
26+
LocalKeyStore.setKey(this.getStorageKey(service), null, (error) => {
27+
resolve();
28+
});
29+
});
30+
},
31+
32+
getStorageKey(service) {
33+
return `${KEYCHAIN_STORAGE_KEY}-${service}`;
34+
},
35+
36+
};
37+
38+
export default KeyChain;

App/Platform/Keychain.ios.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import * as KeyChain from 'react-native-keychain';
2+
3+
export default KeyChain;

App/Platform/Linking.js

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
let NavigatorNavigationBarStyles = require('NavigatorNavigationBarStylesAndroid');
2+
3+
NavigatorNavigationBarStyles.General.TotalNavHeight = 48;
4+
5+
export default NavigatorNavigationBarStyles;

0 commit comments

Comments
 (0)