Skip to content

Commit 6a4daec

Browse files
authored
Merge pull request #8 from TriPSs/improvements
Improvements
2 parents 38a2b1d + 91bde3f commit 6a4daec

File tree

18 files changed

+136
-628
lines changed

18 files changed

+136
-628
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ coverage/
6161

6262
# Cache
6363
cache/
64+
65+
android/app/src/main/assets/index.android.bundle
66+
android/app/src/main/assets/index.android.bundle.meta

android/app/build.gradle

+5-4
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ def enableSeparateBuildPerCPUArchitecture = false
100100
def enableProguardInReleaseBuilds = false
101101

102102
android {
103-
compileSdkVersion 23
103+
compileSdkVersion 26
104104
buildToolsVersion "28.0.2"
105105

106106
defaultConfig {
107107
applicationId "com.popcorn"
108108
minSdkVersion 16
109-
targetSdkVersion 22
110-
versionCode 6
111-
versionName "v0.6.0"
109+
targetSdkVersion 26
110+
versionCode 7
111+
versionName "v0.6.1"
112112
ndk {
113113
abiFilters "armeabi-v7a", "x86"
114114
}
@@ -168,6 +168,7 @@ android {
168168
}
169169

170170
dependencies {
171+
compile project(':react-native-splash-screen')
171172
compile project(':react-native-languages')
172173
compile project(':update-react-native-app')
173174
compile project(':react-native-vector-icons')

android/app/src/main/assets/index.android.bundle

-568
This file was deleted.

android/app/src/main/assets/index.android.bundle.meta

-1
This file was deleted.

android/app/src/main/java/com/popcorn/MainActivity.java

+9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
package com.popcorn;
22

3+
import android.os.Bundle;
34
import com.facebook.react.GoogleCastActivity;
45
import android.content.Intent;
56
import android.content.res.Configuration;
67

8+
import org.devio.rn.splashscreen.SplashScreen;
9+
710
public class MainActivity extends GoogleCastActivity {
811

12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
SplashScreen.show(this, R.style.SplashTheme);
15+
super.onCreate(savedInstanceState);
16+
}
17+
918
/**
1019
* Returns the name of the main component registered from JavaScript.
1120
* This is used to schedule rendering of the component.

android/app/src/main/java/com/popcorn/MainApplication.java

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.facebook.react.ReactApplication;
6+
import org.devio.rn.splashscreen.SplashScreenReactPackage;
67
import com.reactcommunity.rnlanguages.RNLanguagesPackage;
78
import com.tripss.updaternapp.UpdateRNAppPackage;
89
import com.oblador.vectoricons.VectorIconsPackage;
@@ -33,6 +34,7 @@ public boolean getUseDeveloperSupport() {
3334
protected List<ReactPackage> getPackages() {
3435
return Arrays.<ReactPackage>asList(
3536
new MainReactPackage(),
37+
new SplashScreenReactPackage(),
3638
new RNLanguagesPackage(),
3739
new UpdateRNAppPackage(),
3840
new VectorIconsPackage(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<item android:drawable="@color/background"/>
5+
6+
<item
7+
android:width="100dp"
8+
android:height="100dp"
9+
android:drawable="@mipmap/logo"
10+
android:gravity="center" />
11+
12+
</layer-list>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical" android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="@drawable/splash">
6+
</LinearLayout>
832 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="background">#17181b</color>
4+
</resources>

android/app/src/main/res/values/styles.xml

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
<!-- Customize your theme here. -->
66

77
<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem</item>
8-
<item name="android:navigationBarColor">#17181b</item>
9-
8+
<item name="android:navigationBarColor">@color/background</item>
109
</style>
1110

11+
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
12+
<item name="android:statusBarColor">@color/background</item>
13+
<item name="android:navigationBarColor">@color/background</item>
14+
</style>
1215

1316
<style name="SpinnerDropDownItem" parent="Theme.AppCompat.Light.NoActionBar">>
1417
<item name="android:textColor">#ffffff</item>
1518
<item name="android:textSize">18dp</item>
1619
<item name="android:fontFamily">sans-serif-light</item>
1720
<item name="android:gravity">center</item>
18-
<item name="android:background">#17181b</item>
21+
<item name="android:background">@color/background</item>
1922
</style>
2023

2124
</resources>

android/settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
rootProject.name = 'popcorn'
2+
include ':react-native-splash-screen'
3+
project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')
24
include ':react-native-languages'
35
project(':react-native-languages').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-languages/android')
46
include ':update-react-native-app'

app/components/Disclaimer/Disclaimer.js

+55-41
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { StyleSheet, BackHandler, View, ScrollView, StatusBar } from 'react-nati
66
import * as Animatable from 'react-native-animatable'
77
import Markdown from 'react-native-markdown-renderer'
88
import { material } from 'react-native-typography'
9+
import SplashScreen from 'react-native-splash-screen'
910

1011
import i18n from 'modules/i18n'
1112
import colors from 'modules/colors'
1213
import Settings from 'modules/db/Settings'
1314

1415
import Typography from '../Typography'
15-
import FullScreenLoading from '../FullScreenLoading'
1616
import Button from '../Button'
1717

1818
export const styles = StyleSheet.create({
@@ -83,57 +83,69 @@ export default class CheckForUpdates extends React.Component {
8383
}
8484

8585
state = {
86-
accepted: false,
87-
loading : true,
86+
accepted : false,
87+
animating: false,
88+
loading : true,
8889
}
8990

9091
componentWillMount() {
9192
Settings.getItem(Settings.DISCLAIMER_ACCEPTED).then((accepted) => {
9293
this.setState({
9394
accepted: accepted && accepted === 'y',
9495
loading : false,
96+
}, () => {
97+
if (!accepted) {
98+
SplashScreen.hide()
99+
}
95100
})
96101
})
97102
}
98103

104+
handleAnimationEnd = () => {
105+
this.setState({
106+
animating: false,
107+
})
108+
}
109+
99110
handleLeave = () => {
100111
BackHandler.exitApp()
101112
}
102113

103114
handleAccept = () => {
104-
Settings.setItem(Settings.DISCLAIMER_ACCEPTED, 'y')
105-
106115
this.setState({
107-
accepted: true,
116+
accepted : true,
117+
animating: true,
118+
}, () => {
119+
Settings.setItem(Settings.DISCLAIMER_ACCEPTED, 'y')
108120
})
109121
}
110122

111123
render() {
112124
const { children } = this.props
113-
const { accepted, loading } = this.state
114-
115-
if (accepted) {
116-
return children
117-
}
125+
const { animating, accepted, loading } = this.state
118126

119127
return (
120-
<Animatable.View
121-
animation={!accepted ? 'fadeIn' : 'fadeOut'}
122-
duration={500}
123-
style={styles.root}
124-
useNativeDriver>
128+
<React.Fragment>
129+
130+
{children}
125131

126-
<FullScreenLoading enabled={loading} />
132+
{(!accepted || animating) && (
133+
<Animatable.View
134+
animation={!accepted ? 'fadeIn' : 'fadeOut'}
135+
duration={500}
136+
style={styles.root}
137+
onAnimationEnd={this.handleAnimationEnd}
138+
useNativeDriver>
127139

128-
<StatusBar backgroundColor={colors.BACKGROUND} animated />
140+
<StatusBar backgroundColor={colors.BACKGROUND} animated translucent />
129141

130-
<Typography variant={'headline'} style={styles.title}>
131-
{i18n.t('Terms of Service')}
132-
</Typography>
142+
<Typography variant={'headline'} style={styles.title}>
143+
{i18n.t('Terms of Service')}
144+
</Typography>
133145

134-
<ScrollView style={styles.bodyContainer}>
135-
<Markdown style={mdStyle}>
136-
{`## Your Acceptance
146+
<ScrollView style={styles.bodyContainer}>
147+
<Markdown style={mdStyle}>
148+
{`## Your Acceptance
137149
By using the Popcorn Time app you signify your agreement to (1) these terms and conditions (the 'Terms of Service').
138150
139151
## Privacy Policy.
@@ -151,23 +163,25 @@ ALL MOVIES ARE NOT HOSTED ON ANY SERVER AND ARE STREAMED USING THE P2P BIT TORRE
151163
## Ability to Accept Terms of Service
152164
By using Popcorn Time or accessing this site you affirm that you are either more than 18 years of age, or an emancipated minor, or possess legal parental or guardian consent, and are fully able and competent to enter into the terms, conditions, obligations, affirmations, representations, and warranties set forth in these Terms of Service, and to abide by and comply with these Terms of Service. In any case, you affirm that you are over the age of 13, as the Service is not intended for children under 13. If you are under 13 years of age, then please do not use the Service. There are lots of other great web sites for you. Talk to your parents about what sites are appropriate for you.
153165
`}
154-
</Markdown>
155-
</ScrollView>
156-
157-
<View style={styles.actions}>
158-
<Button
159-
onPress={this.handleLeave}>
160-
{i18n.t('leave')}
161-
</Button>
162-
163-
<Button
164-
variant={'primary'}
165-
onPress={this.handleAccept}>
166-
{i18n.t('i accept')}
167-
</Button>
168-
</View>
169-
170-
</Animatable.View>
166+
</Markdown>
167+
</ScrollView>
168+
169+
<View style={styles.actions}>
170+
<Button
171+
onPress={this.handleLeave}>
172+
{i18n.t('leave')}
173+
</Button>
174+
175+
<Button
176+
variant={'primary'}
177+
onPress={this.handleAccept}>
178+
{i18n.t('i accept')}
179+
</Button>
180+
</View>
181+
182+
</Animatable.View>
183+
)}
184+
</React.Fragment>
171185
)
172186
}
173187
}

app/modules/i18n/i18n.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ import translations from './translations'
66
i18n.locale = RNLanguages.language
77
i18n.fallbacks = true
88
i18n.translations = translations
9+
i18n.missingBehaviour = __DEV__ ? 'messages' : 'guess'
910

1011
export default i18n

app/screens/Home/HomeScreen.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import PropTypes from 'prop-types'
33
import { StyleSheet, Text, View } from 'react-native'
44
import Orientation from 'react-native-orientation'
55
import { Constants } from 'popcorn-sdk'
6+
import SplashScreen from 'react-native-splash-screen'
67

78
import i18n from 'modules/i18n'
89
import colors from 'modules/colors'
910

1011
import CardList from 'components/CardList'
1112
import MainCover from 'components/MainCover'
12-
import FullScreenLoading from 'components/FullScreenLoading'
1313
import ScrollViewWithStatusBar from 'components/ScrollViewWithStatusBar'
1414

1515
const styles = StyleSheet.create({
@@ -36,10 +36,6 @@ export default class Home extends React.PureComponent {
3636
hasInternet: true,
3737
}
3838

39-
state = {
40-
loading: true,
41-
}
42-
4339
componentDidMount() {
4440
const { getItems } = this.props
4541

@@ -59,7 +55,9 @@ export default class Home extends React.PureComponent {
5955
navigation.navigate('Item', item)
6056
}
6157

62-
handleCoverLoaded = () => this.setState({ loading: false })
58+
handleCoverLoaded = () => {
59+
SplashScreen.hide()
60+
}
6361

6462
getMainCover = () => {
6563
const movies = this.getMovies(false)
@@ -93,13 +91,10 @@ export default class Home extends React.PureComponent {
9391

9492
render() {
9593
const { isLoading, hasInternet } = this.props
96-
const { loading } = this.state
9794

9895
return (
9996
<View style={styles.root}>
10097

101-
<FullScreenLoading enabled={isLoading || loading} />
102-
10398
{hasInternet && (
10499
<ScrollViewWithStatusBar>
105100

0 commit comments

Comments
 (0)