Compare commits

..
27 Commits
Author SHA1 Message Date
Akinwale Ariwodola b8ad99b2a1 bumpversion 2018-04-24 21:02:50 +01:00
akinwale 68cec1659a Merge pull request #84 from lbryio/release-script
created a release script
2018-04-24 21:01:58 +01:00
Akinwale Ariwodola a7264e506a created a release script 2018-04-24 21:01:11 +01:00
akinwale 90d17604fc First run timing (#83)
* first run time tracking implementation
* Fix values in AsyncStorage calls. Some tweaks to Mixpanel event properties.
* remove first launch related items in AsyncStorage after final retrieval
2018-04-24 20:32:17 +01:00
akinwale 77a86da984 Merge pull request #79 from lbryio/service-notification
Removed service foreground notification
2018-04-24 15:59:20 +01:00
akinwale 41becae272 Merge pull request #80 from lbryio/background-play
added new setting to toggle background media play
2018-04-23 22:22:40 +01:00
akinwale 21640e4264 Merge pull request #81 from lbryio/search-drawer-locked
keep navigation drawer locked in the closed state on the search screen
2018-04-23 17:23:37 +01:00
Akinwale Ariwodola 1366dc0996 keep navigation drawer locked in the closed state on the search screen 2018-04-23 10:34:45 +01:00
Akinwale Ariwodola c6129ffc31 added new setting to toggle background media play 2018-04-23 10:26:09 +01:00
Akinwale Ariwodola d018e9b577 Removed service foreground notification. Tapping on the download progress notification should open the app. 2018-04-23 05:32:19 +01:00
akinwale 496ec53f8a About page (#78)
* added about page with version info
* lock drawer to closed state for About screen. Added About screen hardware back button handling.
2018-04-23 05:10:18 +01:00
akinwale b9e0065aad added single page header with back button and some styling (#75)
* added single page header with back button and some styling
* lock drawer mode state to closed for settings screen
2018-04-23 05:01:33 +01:00
akinwale a4798c3cf9 Merge pull request #68 from lbryio/mixpanel
Implemented Mixpanel analytics
2018-04-23 05:00:38 +01:00
Sean Yesmunt 7a335515f6 Merge pull request #76 from lbryio/splash-screen-title
change Lbry. to LBRY on splash screen
2018-04-22 23:14:27 -04:00
Akinwale Ariwodola a8457a748a change Lbry. to LBRY on splash screen 2018-04-21 10:58:25 +01:00
Akinwale Ariwodola bb7fa61c33 Implemented Mixpanel analytics 2018-04-20 03:14:44 +01:00
akinwale 5d8d832e99 Merge pull request #67 from lbryio/dismissable-and-grouped-notifications
Allow download notifications to be dismissed. Group active download notifications.
2018-04-19 23:59:05 +01:00
Akinwale Ariwodola 0bb215a803 Allow download notifications to be dismissed. Group active download notifications. 2018-04-19 22:43:15 +01:00
akinwale 173920d9eb Merge pull request #63 from lbryio/delete-button-fullscreen-fix
fix action buttons displaying in full screen video mode
2018-04-12 13:11:14 -04:00
akinwale 1fb5ce87ea Merge pull request #64 from lbryio/crash-on-start
Integrate fixes from https://github.com/kivy/python-for-android/pull/1197
2018-04-11 12:05:40 -04:00
Akinwale Ariwodola 43deedd994 Integrate fixes from https://github.com/kivy/python-for-android/pull/1197 for minimum Android API support. Minimum Android API set to 21. 2018-04-11 11:30:16 -04:00
Akinwale Ariwodola 2d72afe1f0 fix action buttons displaying in full screen video mode 2018-04-11 11:13:32 -04:00
Akinwale Ariwodola a90c795891 bumpversion 2018-04-09 14:59:11 -04:00
akinwale 1e32b6e875 Search result item component and search page (#60)
* Implemented SearchResultItem component and search page
2018-04-09 14:39:35 -04:00
akinwale 0f454b562d Merge pull request #59 from lbryio/persist-settings
fix for settings not being persisted in store
2018-04-09 14:38:58 -04:00
akinwale db86a723a5 Create issue_template.md (#50) 2018-04-06 11:29:11 +01:00
Akinwale Ariwodola c0818b056d fix for settings not being persisted in store 2018-04-04 17:29:19 +01:00
49 changed files with 1258 additions and 4941 deletions

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
<!--
Thanks for reporting an issue to LBRY and helping us improve!
To make it possible for us to help you, please fill out below information carefully.
Before reporting any issues, please make sure that you're using the latest version.
We are also available on live chat at https://chat.lbry.io
-->
## The Issue
### Steps to reproduce
1.
2.
3.
### Expected behaviour
Tell us what should happen
### Actual behaviour
Tell us what happens instead
## System Configuration
- Device:
- Android version:
## Anything Else
<!-- Include anything else that does not fit into the above sections -->
## Screenshots
<!-- If a screenshot would help explain the bug, please include one or two here -->
+268 -4848
View File
File diff suppressed because it is too large. Load diff
+7 -1
View File
@@ -7,7 +7,8 @@
"postinstall": "cp ./patch/ReactNativeRenderer-dev.js.patch ./node_modules/react-native/Libraries/Renderer/ReactNativeRenderer-dev.js; rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json"
},
"dependencies": {
"lbry-redux": "lbryio/lbry-redux#common-components-refactor",
"lbry-redux": "lbryio/lbry-redux",
"moment": "^2.22.1",
"react": "16.2.0",
"react-native": "0.52.0",
"react-native-vector-icons": "^4.5.0",
@@ -21,5 +22,10 @@
"redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.10",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-preset-env": "^1.6.1",
"babel-preset-stage-2": "^6.18.0",
"flow-babel-webpack-plugin": "^1.1.1"
}
}
+54 -19
View File
@@ -1,23 +1,39 @@
import React from 'react';
import DiscoverPage from '../page/discover';
import FilePage from '../page/file';
import SearchPage from '../page/search';
import SettingsPage from '../page/settings';
import AboutPage from '../page/about';
import SplashScreen from '../page/splash';
import { addNavigationHelpers, DrawerNavigator, StackNavigator } from 'react-navigation';
import SearchInput from '../component/searchInput';
import {
addNavigationHelpers,
DrawerNavigator,
StackNavigator,
NavigationActions
} from 'react-navigation';
import { connect } from 'react-redux';
import { addListener } from '../utils/redux';
import { AppState, BackHandler, NativeModules } from 'react-native';
import {
AppState,
AsyncStorage,
BackHandler,
NativeModules,
TextInput
} from 'react-native';
import { SETTINGS } from 'lbry-redux';
import { makeSelectClientSetting } from '../redux/selectors/settings';
import Feather from 'react-native-vector-icons/Feather';
import discoverStyle from '../styles/discover';
import { makeSelectClientSetting } from '../redux/selectors/settings';
import searchStyle from '../styles/search';
const discoverStack = StackNavigator({
Discover: {
screen: DiscoverPage,
navigationOptions: ({ navigation }) => ({
title: 'Discover',
headerLeft: <Feather name="menu" size={24} style={discoverStyle.drawerHamburger} onPress={() => navigation.navigate('DrawerOpen')} />
headerLeft: <Feather name="menu" size={24} style={discoverStyle.drawerHamburger} onPress={() => navigation.navigate('DrawerOpen')} />,
headerRight: <Feather name="search" size={24} style={discoverStyle.rightHeaderIcon} onPress={() => navigation.navigate('Search')} />
})
},
File: {
@@ -26,6 +42,14 @@ const discoverStack = StackNavigator({
header: null,
drawerLockMode: 'locked-closed'
}
},
Search: {
screen: SearchPage,
navigationOptions: ({ navigation }) => ({
drawerLockMode: 'locked-closed',
headerTitle: <SearchInput style={searchStyle.searchInput} />,
headerRight: <Feather name="x" size={24} style={discoverStyle.rightHeaderIcon} onPress={() => navigation.dispatch(NavigationActions.back())} />
})
}
}, {
headerMode: 'screen',
@@ -33,10 +57,8 @@ const discoverStack = StackNavigator({
const drawer = DrawerNavigator({
Discover: { screen: discoverStack },
Settings: {
screen: SettingsPage,
headerMode: 'screen'
}
Settings: { screen: SettingsPage, navigationOptions: { drawerLockMode: 'locked-closed' } },
About: { screen: AboutPage, navigationOptions: { drawerLockMode: 'locked-closed' } }
}, {
drawerWidth: 300,
headerMode: 'none'
@@ -44,7 +66,10 @@ const drawer = DrawerNavigator({
export const AppNavigator = new StackNavigator({
Splash: {
screen: SplashScreen
screen: SplashScreen,
navigationOptions: {
drawerLockMode: 'locked-closed'
}
},
Main: {
screen: drawer
@@ -58,11 +83,20 @@ class AppWithNavigationState extends React.Component {
AppState.addEventListener('change', this._handleAppStateChange);
BackHandler.addEventListener('hardwareBackPress', function() {
const { dispatch, navigation, nav } = this.props;
if (nav.routes.length === 2 && nav.routes[1].routeName === 'Main') {
if (nav.routes[1].routes[0].routes[0].index > 0) {
// There should be a better way to check this
if (nav.routes.length > 1) {
const subRoutes = nav.routes[1].routes[0].routes;
const lastRoute = subRoutes[subRoutes.length - 1];
if (['About', 'Settings'].indexOf(lastRoute.key) > -1) {
dispatch({ type: 'Navigation/BACK' });
return true;
}
if (nav.routes[1].routeName === 'Main') {
if (nav.routes[1].routes[0].routes[0].index > 0) {
dispatch({ type: 'Navigation/BACK' });
return true;
}
}
}
return false;
}.bind(this));
@@ -74,14 +108,15 @@ class AppWithNavigationState extends React.Component {
}
_handleAppStateChange = (nextAppState) => {
const { keepDaemonRunning } = this.props;
if (AppState.currentState &&
AppState.currentState.match(/inactive|background/) &&
NativeModules.DaemonServiceControl) {
if (!keepDaemonRunning) {
// terminate the daemon background service when is suspended / inactive
NativeModules.DaemonServiceControl.stopService();
}
// Check if the app was suspended
if (AppState.currentState && AppState.currentState.match(/inactive|background/)) {
AsyncStorage.getItem('firstLaunchTime').then(start => {
if (start !== null && !isNaN(parseInt(start, 10))) {
// App suspended during first launch?
// If so, this needs to be included as a property when tracking
AsyncStorage.setItem('firstLaunchSuspended', 'true');
}
});
}
}
+4 -1
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { Text, View, TouchableOpacity } from 'react-native';
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
import fileDownloadButtonStyle from '../../styles/fileDownloadButton';
class FileDownloadButton extends React.PureComponent {
@@ -60,6 +60,9 @@ class FileDownloadButton extends React.PureComponent {
}
return (
<TouchableOpacity style={[style, fileDownloadButtonStyle.container]} onPress={() => {
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('Purchase Uri', { Uri: uri });
}
purchaseUri(uri);
}}>
<Text style={fileDownloadButtonStyle.text}>Download</Text>
+4 -1
View File
@@ -1,7 +1,7 @@
import React from 'react';
import { normalizeURI } from 'lbry-redux';
import { NavigationActions } from 'react-navigation';
import { Text, View, TouchableOpacity } from 'react-native';
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
import FileItemMedia from '../fileItemMedia';
import FilePrice from '../filePrice';
import NsfwOverlay from '../nsfwOverlay';
@@ -58,6 +58,9 @@ class FileItem extends React.PureComponent {
return (
<View style={style}>
<TouchableOpacity style={discoverStyle.container} onPress={() => {
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('Discover Tap', { Uri: uri });
}
navigation.navigate('File', { uri: uri });
}
}>
+1 -1
View File
@@ -45,7 +45,7 @@ class FileItemMedia extends React.PureComponent {
}
return (
<View style={[fileItemMediaStyle.autothumb, atStyle]}>
<View style={[style ? style : fileItemMediaStyle.autothumb, atStyle]}>
<Text style={fileItemMediaStyle.autothumbText}>{title &&
title
.replace(/\s+/g, '')
+5 -1
View File
@@ -1,7 +1,11 @@
import { connect } from 'react-redux';
import { SETTINGS } from 'lbry-redux';
import { makeSelectClientSetting } from '../../redux/selectors/settings';
import MediaPlayer from './view';
const select = state => ({});
const select = state => ({
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
});
const perform = dispatch => ({});
export default connect(select, perform)(MediaPlayer);
+14 -3
View File
@@ -1,6 +1,13 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { PanResponder, Text, View, ScrollView, TouchableOpacity } from 'react-native';
import {
NativeModules,
PanResponder,
Text,
View,
ScrollView,
TouchableOpacity
} from 'react-native';
import Video from 'react-native-video';
import Icon from 'react-native-vector-icons/FontAwesome';
import FileItemMedia from '../fileItemMedia';
@@ -76,6 +83,10 @@ class MediaPlayer extends React.PureComponent {
}
if (this.state.firstPlay) {
if (NativeModules.Mixpanel) {
const { uri } = this.props;
NativeModules.Mixpanel.track('Play', { Uri: uri });
}
this.setState({ firstPlay: false });
this.hidePlayerControls();
}
@@ -232,7 +243,7 @@ class MediaPlayer extends React.PureComponent {
}
render() {
const { fileInfo, title, thumbnail, style, fullScreenStyle } = this.props;
const { backgroundPlayEnabled, fileInfo, thumbnail, style, fullScreenStyle } = this.props;
const flexCompleted = this.getCurrentTimePercentage() * 100;
const flexRemaining = (1 - this.getCurrentTimePercentage()) * 100;
@@ -241,7 +252,7 @@ class MediaPlayer extends React.PureComponent {
<Video source={{ uri: 'file:///' + fileInfo.download_path }}
ref={(ref: Video) => { this.video = ref }}
resizeMode={this.state.resizeMode}
playInBackground={true}
playInBackground={backgroundPlayEnabled}
style={mediaPlayerStyle.player}
rate={this.state.rate}
volume={this.state.volume}
+6
View File
@@ -0,0 +1,6 @@
import { connect } from 'react-redux';
import PageHeader from './view';
const perform = dispatch => ({});
export default connect(null, perform)(PageHeader);
+47
View File
@@ -0,0 +1,47 @@
// Based on https://github.com/react-navigation/react-navigation/blob/master/src/views/Header/Header.js
import React from 'react';
import {
Animated,
Platform,
StyleSheet,
Text,
TouchableOpacity,
View
} from 'react-native';
import Feather from 'react-native-vector-icons/Feather';
import pageHeaderStyle from '../../styles/pageHeader';
const APPBAR_HEIGHT = Platform.OS === 'ios' ? 44 : 56;
const AnimatedText = Animated.Text;
class PageHeader extends React.PureComponent {
render() {
const { title, onBackPressed } = this.props;
const containerStyles = [
pageHeaderStyle.container,
{ height: APPBAR_HEIGHT }
];
return (
<View style={containerStyles}>
<View style={pageHeaderStyle.flexOne}>
<View style={pageHeaderStyle.header}>
<View style={pageHeaderStyle.title}>
<AnimatedText
numberOfLines={1}
style={pageHeaderStyle.titleText}
accessibilityTraits="header">
{title}
</AnimatedText>
</View>
<TouchableOpacity style={pageHeaderStyle.left}>
<Feather name="arrow-left" size={24} onPress={onBackPressed} style={pageHeaderStyle.backIcon} />
</TouchableOpacity>
</View>
</View>
</View>
);
}
}
export default PageHeader;
+16
View File
@@ -0,0 +1,16 @@
import { connect } from 'react-redux';
import { NativeModules } from 'react-native';
import { doSearch, doUpdateSearchQuery } from 'lbry-redux';
import SearchInput from './view';
const perform = dispatch => ({
search: search => {
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('Search', { Query: search });
}
return dispatch(doSearch(search));
},
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query, false))
});
export default connect(null, perform)(SearchInput);
+40
View File
@@ -0,0 +1,40 @@
import React from 'react';
import { TextInput } from 'react-native';
class SearchInput extends React.PureComponent {
static INPUT_TIMEOUT = 500;
state = {
changeTextTimeout: -1
};
handleChangeText = text => {
clearTimeout(this.state.changeTextTimeout);
if (!text || text.trim().length < 2) {
// only perform a search if 2 or more characters have been input
return;
}
const { search, updateSearchQuery } = this.props;
updateSearchQuery(text);
let timeout = setTimeout(() => {
search(text);
}, SearchInput.INPUT_TIMEOUT);
this.setState({ changeTextTimeout: timeout });
}
render() {
const { style, value } = this.props;
return (
<TextInput
style={style}
placeholder="Search"
underlineColorAndroid="transparent"
value={value}
onChangeText={text => this.handleChangeText(text)} />
);
}
}
export default SearchInput;
@@ -0,0 +1,24 @@
import { connect } from 'react-redux';
import {
doResolveUri,
makeSelectClaimForUri,
makeSelectMetadataForUri,
makeSelectFileInfoForUri,
makeSelectIsUriResolving,
} from 'lbry-redux';
import { selectShowNsfw } from '../../redux/selectors/settings';
import SearchResultItem from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
isDownloaded: !!makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
obscureNsfw: !selectShowNsfw(state)
});
const perform = dispatch => ({
resolveUri: uri => dispatch(doResolveUri(uri))
});
export default connect(select, perform)(SearchResultItem);
@@ -0,0 +1,53 @@
import React from 'react';
import { normalizeURI, parseURI } from 'lbry-redux';
import { Text, TouchableOpacity, View } from 'react-native';
import FileItemMedia from '../fileItemMedia';
import NsfwOverlay from '../../component/nsfwOverlay';
import searchStyle from '../../styles/search';
class SearchResultItem extends React.PureComponent {
render() {
const {
claim,
metadata,
isResolvingUri,
showUri,
isDownloaded,
style,
onPress,
navigation
} = this.props;
const uri = normalizeURI(this.props.uri);
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
const title = metadata && metadata.title ? metadata.title : parseURI(uri).contentName;
let name;
let channel;
if (claim) {
name = claim.name;
channel = claim.channel_name;
}
return (
<View style={style}>
<TouchableOpacity style={style} onPress={onPress}>
<View style={searchStyle.thumbnailContainer}>
<FileItemMedia style={searchStyle.thumbnail}
blurRadius={obscureNsfw ? 15 : 0}
title={title}
thumbnail={metadata ? metadata.thumbnail : null} />
</View>
<View style={searchStyle.detailsContainer}>
{isResolvingUri && <Text style={searchStyle.loading}>Loading...</Text>}
{!isResolvingUri && <Text style={searchStyle.title}>{title || name}</Text>}
{!isResolvingUri && channel && <Text style={searchStyle.publisher}>{channel}</Text>}
</View>
</TouchableOpacity>
{obscureNsfw && <NsfwOverlay onPress={() => navigation.navigate('Settings')} />}
</View>
);
}
}
export default SearchResultItem;
+19 -1
View File
@@ -1,7 +1,14 @@
import React from 'react';
import { Provider, connect } from 'react-redux';
import DiscoverPage from './page/discover';
import { AppRegistry, AppState, StyleSheet, Text, View, AsyncStorage, NativeModules } from 'react-native';
import {
AppRegistry,
AppState,
AsyncStorage,
Text,
View,
NativeModules
} from 'react-native';
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import {
StackNavigator, addNavigationHelpers
@@ -21,6 +28,7 @@ import {
walletReducer
} from 'lbry-redux';
import settingsReducer from './redux/reducers/settings';
import moment from 'moment';
import { reactNavigationMiddleware } from './utils/redux';
function isFunction(object) {
@@ -105,6 +113,16 @@ persistStore(store, persistOptions, err => {
});
class LBRYApp extends React.Component {
componentDidMount() {
AsyncStorage.getItem('hasLaunched').then(value => {
if (value == null || value !== 'true') {
AsyncStorage.setItem('hasLaunched', 'true');
// only set firstLaunchTime since we've determined that this is the first app launch ever
AsyncStorage.setItem('firstLaunchTime', String(moment().unix()));
}
});
}
render() {
return (
<Provider store={store}>
+6
View File
@@ -0,0 +1,6 @@
import { connect } from 'react-redux';
import AboutPage from './view';
const perform = dispatch => ({});
export default connect(null, perform)(AboutPage);
+74
View File
@@ -0,0 +1,74 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { NativeModules, Text, View, ScrollView } from 'react-native';
import PageHeader from '../../component/pageHeader';
import aboutStyle from '../../styles/about';
class AboutPage extends React.PureComponent {
state = {
appVersion: null,
lbryId: null,
versionInfo: null
};
componentDidMount() {
if (NativeModules.VersionInfo) {
NativeModules.VersionInfo.getAppVersion().then(version => {
this.setState({appVersion: version});
});
}
Lbry.version().then(info => {
this.setState({
versionInfo: info,
});
});
Lbry.status({ session_status: true }).then(info => {
this.setState({
lbryId: info.lbry_id,
});
});
}
render() {
const loading = 'Loading...';
const ver = this.state.versionInfo ? this.state.versionInfo : null;
return (
<View>
<PageHeader title={"About LBRY"}
onBackPressed={() => { this.props.navigation.goBack(); }} />
<ScrollView style={aboutStyle.scrollContainer}>
<Text style={aboutStyle.releaseInfoTitle}>Release information</Text>
<View style={aboutStyle.row}>
<View style={aboutStyle.col}><Text style={aboutStyle.text}>App version</Text></View>
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{this.state.appVersion}</Text></View>
</View>
<View style={aboutStyle.row}>
<View style={aboutStyle.col}><Text style={aboutStyle.text}>Daemon (lbrynet)</Text></View>
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{ver ? ver.lbrynet_version : loading }</Text></View>
</View>
<View style={aboutStyle.row}>
<View style={aboutStyle.col}><Text style={aboutStyle.text}>Wallet (lbryum)</Text></View>
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{ver ? ver.lbryum_version : loading }</Text></View>
</View>
<View style={aboutStyle.row}>
<View style={aboutStyle.col}><Text style={aboutStyle.text}>Platform</Text></View>
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{ver ? ver.platform : loading }</Text></View>
</View>
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>Installation ID</Text>
<Text selectable={true} style={aboutStyle.lineValueText}>{this.state.lbryId ? this.state.lbryId : loading}</Text>
</View>
</View>
</ScrollView>
</View>
);
}
}
export default AboutPage;
+24 -1
View File
@@ -1,12 +1,35 @@
import React from 'react';
import FeaturedCategory from '../../component/featuredCategory';
import NavigationActions from 'react-navigation';
import { Text, View, ScrollView } from 'react-native';
import { AsyncStorage, NativeModules, ScrollView, Text, View } from 'react-native';
import moment from 'moment';
import discoverStyle from '../../styles/discover';
import Feather from 'react-native-vector-icons/Feather';
class DiscoverPage extends React.PureComponent {
componentWillMount() {
// Track the total time taken if this is the first launch
AsyncStorage.getItem('firstLaunchTime').then(startTime => {
if (startTime !== null && !isNaN(parseInt(startTime, 10))) {
// We don't need this value anymore once we've retrieved it
AsyncStorage.removeItem('firstLaunchTime');
// We know this is the first app launch because firstLaunchTime is set and it's a valid number
const start = parseInt(startTime, 10);
const now = moment().unix();
const delta = now - start;
AsyncStorage.getItem('firstLaunchSuspended').then(suspended => {
AsyncStorage.removeItem('firstLaunchSuspended');
const appSuspended = (suspended === 'true');
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('First Run Time', {
'Total Seconds': delta, 'App Suspended': appSuspended
});
}
});
}
});
this.props.fetchFeaturedUris();
}
+7 -2
View File
@@ -11,6 +11,7 @@ import {
TouchableOpacity,
NativeModules
} from 'react-native';
import Colors from '../../styles/colors';
import FileItemMedia from '../../component/fileItemMedia';
import FileDownloadButton from '../../component/fileDownloadButton';
import MediaPlayer from '../../component/mediaPlayer';
@@ -31,6 +32,9 @@ class FilePage extends React.PureComponent {
StatusBar.setHidden(false);
this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('Open File Page', { Uri: this.props.navigation.state.params.uri });
}
}
componentWillReceiveProps(nextProps) {
@@ -123,7 +127,7 @@ class FilePage extends React.PureComponent {
const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio';
const { height, channel_name: channelName, value } = claim;
const showActions = (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const showActions = !this.state.fullscreenMode && (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const channelClaimId =
value && value.publisherSignature && value.publisherSignature.certificateId;
@@ -132,9 +136,10 @@ class FilePage extends React.PureComponent {
<View style={this.state.fullscreenMode ? filePageStyle.fullscreenMedia : filePageStyle.mediaContainer}>
{(!fileInfo || (isPlayable && !this.state.mediaLoaded)) &&
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={metadata.thumbnail} />}
{isPlayable && !this.state.mediaLoaded && <ActivityIndicator size="large" color="#40b89a" style={filePageStyle.loading} />}
{isPlayable && !this.state.mediaLoaded && <ActivityIndicator size="large" color={Colors.LbryGreen} style={filePageStyle.loading} />}
{!completed && <FileDownloadButton uri={navigation.state.params.uri} style={filePageStyle.downloadButton} />}
{fileInfo && isPlayable && <MediaPlayer fileInfo={fileInfo}
uri={navigation.state.params.uri}
style={filePageStyle.player}
onFullscreenToggled={this.handleFullscreenToggle}
onMediaLoaded={() => { this.setState({ mediaLoaded: true }); }}/>}
+20
View File
@@ -0,0 +1,20 @@
import { connect } from 'react-redux';
import {
doSearch,
makeSelectSearchUris,
selectIsSearching,
selectSearchValue
} from 'lbry-redux';
import SearchPage from './view';
const select = (state) => ({
isSearching: selectIsSearching(state),
query: selectSearchValue(state),
uris: makeSelectSearchUris(selectSearchValue(state))(state)
});
const perform = dispatch => ({
search: (query) => dispatch(doSearch(query))
});
export default connect(select, perform)(SearchPage);
+38
View File
@@ -0,0 +1,38 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import {
ActivityIndicator,
Button,
Text,
TextInput,
View,
ScrollView
} from 'react-native';
import SearchResultItem from '../../component/searchResultItem';
import Colors from '../../styles/colors';
import searchStyle from '../../styles/search';
class SearchPage extends React.PureComponent {
render() {
const { isSearching, navigation, uris } = this.props;
return (
<View style={searchStyle.container}>
{!isSearching && (!uris || uris.length === 0) &&
<Text style={searchStyle.noResultsText}>No results to display.</Text>}
<ScrollView style={searchStyle.scrollContainer} contentContainerStyle={searchStyle.scrollPadding}>
{!isSearching && uris && uris.length ? (
uris.map(uri => <SearchResultItem key={uri}
uri={uri}
style={searchStyle.resultItem}
navigation={navigation}
onPress={() => {navigation.navigate('File', { uri: uri }); }}/>)
) : null }
</ScrollView>
{isSearching && <ActivityIndicator size="large" color={Colors.LbryGreen} style={searchStyle.loading} /> }
</View>
);
}
}
export default SearchPage;
+1
View File
@@ -5,6 +5,7 @@ import { makeSelectClientSetting } from '../../redux/selectors/settings';
import SettingsPage from './view';
const select = state => ({
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
});
+14 -1
View File
@@ -1,6 +1,7 @@
import React from 'react';
import { SETTINGS } from 'lbry-redux';
import { Text, View, ScrollView, Switch } from 'react-native';
import PageHeader from '../../component/pageHeader';
import settingsStyle from '../../styles/settings';
class SettingsPage extends React.PureComponent {
@@ -10,6 +11,7 @@ class SettingsPage extends React.PureComponent {
render() {
const {
backgroundPlayEnabled,
keepDaemonRunning,
showNsfw,
setClientSetting
@@ -17,8 +19,19 @@ class SettingsPage extends React.PureComponent {
return (
<View>
<Text style={settingsStyle.title}>Settings</Text>
<PageHeader title={"Settings"}
onBackPressed={() => { this.props.navigation.goBack(); }} />
<ScrollView style={settingsStyle.scrollContainer}>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>Enable background media playback</Text>
<Text style={settingsStyle.description}>Enable this option to play audio or video in the background when the app is suspended.</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch value={backgroundPlayEnabled} onValueChange={(value) => setClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED, value)} />
</View>
</View>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>Show NSFW content</Text>
+6 -2
View File
@@ -1,6 +1,6 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { View, Text } from 'react-native';
import { View, Text, NativeModules } from 'react-native';
import PropTypes from 'prop-types';
import splashStyle from '../../styles/splash';
@@ -66,6 +66,10 @@ class SplashScreen extends React.PureComponent {
}
componentDidMount() {
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('App Launch', null);
}
Lbry
.connect()
.then(() => {
@@ -86,7 +90,7 @@ class SplashScreen extends React.PureComponent {
return (
<View style={splashStyle.container}>
<Text style={splashStyle.title}>Lbry.</Text>
<Text style={splashStyle.title}>LBRY</Text>
<Text style={splashStyle.message}>{message}</Text>
<Text style={splashStyle.details}>{details}</Text>
</View>
+1 -4
View File
@@ -2,10 +2,7 @@ import { ACTIONS } from 'lbry-redux';
const reducers = {};
const defaultState = {
clientSettings: {
keepDaemonRunning: true,
showNsfw: false
}
clientSettings: {}
};
reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
+41
View File
@@ -0,0 +1,41 @@
import { StyleSheet } from 'react-native';
const aboutStyle = StyleSheet.create({
scrollContainer: {
paddingTop: 16,
paddingBottom: 16
},
row: {
marginBottom: 1,
backgroundColor: '#f9f9f9',
padding: 16,
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between'
},
col: {
alignSelf: 'stretch'
},
releaseInfoTitle: {
fontFamily: 'Metropolis-Regular',
marginLeft: 12,
marginRight: 12,
marginBottom: 12,
fontSize: 14
},
text: {
fontFamily: 'Metropolis-SemiBold',
fontSize: 15
},
valueText: {
fontFamily: 'Metropolis-Regular',
textAlign: 'right',
fontSize: 15
},
lineValueText: {
fontFamily: 'Metropolis-Regular',
fontSize: 15
}
});
export default aboutStyle;
+6
View File
@@ -0,0 +1,6 @@
const Colors = {
LbryGreen: '#40b89a'
};
export default Colors;
+4 -1
View File
@@ -55,7 +55,10 @@ const discoverStyle = StyleSheet.create({
color: '#0c604b'
},
drawerHamburger: {
marginLeft: 8
marginLeft: 16
},
rightHeaderIcon: {
marginRight: 16
},
overlay: {
flex: 1,
+3 -1
View File
@@ -58,7 +58,9 @@ const filePageStyle = StyleSheet.create({
},
thumbnail: {
width: screenWidth,
height: 204
height: 204,
justifyContent: 'center',
alignItems: 'center'
},
downloadButton: {
position: 'absolute',
+81
View File
@@ -0,0 +1,81 @@
import { Platform, StyleSheet } from 'react-native';
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 20 : 0;
const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56;
let platformContainerStyles;
if (Platform.OS === 'ios') {
platformContainerStyles = {
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: '#A7A7AA',
};
} else {
platformContainerStyles = {
shadowColor: 'black',
shadowOpacity: 0.1,
shadowRadius: StyleSheet.hairlineWidth,
shadowOffset: {
height: StyleSheet.hairlineWidth,
},
elevation: 4,
};
}
const pageHeaderStyle = StyleSheet.create({
container: {
backgroundColor: Platform.OS === 'ios' ? '#F7F7F7' : '#FFF',
...platformContainerStyles,
},
transparentContainer: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
...platformContainerStyles,
},
backIcon: {
marginLeft: 16
},
header: {
...StyleSheet.absoluteFillObject,
flexDirection: 'row',
},
titleText: {
fontSize: Platform.OS === 'ios' ? 17 : 20,
fontWeight: Platform.OS === 'ios' ? '700' : '500',
color: 'rgba(0, 0, 0, .9)',
textAlign: Platform.OS === 'ios' ? 'center' : 'left',
marginHorizontal: 16,
},
title: {
bottom: 0,
top: 0,
left: TITLE_OFFSET,
right: TITLE_OFFSET,
position: 'absolute',
alignItems: 'center',
flexDirection: 'row',
justifyContent: Platform.OS === 'ios' ? 'center' : 'flex-start',
},
left: {
left: 0,
bottom: 0,
top: 0,
position: 'absolute',
alignItems: 'center',
flexDirection: 'row',
},
right: {
right: 0,
bottom: 0,
top: 0,
position: 'absolute',
flexDirection: 'row',
alignItems: 'center',
},
flexOne: {
flex: 1,
}
});
export default pageHeaderStyle;
+61
View File
@@ -0,0 +1,61 @@
import { StyleSheet } from 'react-native';
const searchStyle = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
scrollContainer: {
flex: 1,
width: '100%',
height: '100%',
padding: 16
},
scrollPadding: {
paddingBottom: 16
},
resultItem: {
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
marginBottom: 16
},
thumbnail: {
width: '100%',
height: 80
},
thumbnailContainer: {
width: '25%'
},
detailsContainer: {
width: '70%'
},
searchInput: {
width: '100%',
height: '100%',
fontFamily: 'Metropolis-Regular',
fontSize: 16
},
title: {
fontFamily: 'Metropolis-SemiBold',
fontSize: 16
},
publisher: {
fontFamily: 'Metropolis-SemiBold',
fontSize: 12,
marginTop: 4,
color: '#c0c0c0'
},
noResultsText: {
textAlign: 'center',
fontFamily: 'Metropolis-Regular',
fontSize: 14,
position: 'absolute'
},
loading: {
position: 'absolute'
}
});
export default searchStyle;
+1 -3
View File
@@ -7,9 +7,7 @@ const settingsStyle = StyleSheet.create({
margin: 16
},
scrollContainer: {
paddingLeft: 16,
paddingRight: 16,
paddingBottom: 16
padding: 16
},
row: {
marginBottom: 24,
+3 -3
View File
@@ -86,13 +86,13 @@ fullscreen = 0
#android.presplash_color = #FFFFFF
# (list) Permissions
android.permissions = INTERNET,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
android.permissions = ACCESS_NETWORK_STATE,BLUETOOTH,INTERNET,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
# (int) Android API to use
android.api = 23
# (int) Minimum API required
android.minapi = 16
android.minapi = 21
# (int) Android SDK version to use
android.sdk = 23
@@ -148,7 +148,7 @@ android.react_src = ./app
# (list) Gradle dependencies to add (currently works only with sdl2_gradle
# bootstrap)
android.gradle_dependencies = com.android.support:appcompat-v7:23.4.0, com.facebook.react:react-native:+
android.gradle_dependencies = com.android.support:appcompat-v7:23.4.0, com.facebook.react:react-native:+, com.mixpanel.android:mixpanel-android:5+, com.google.android.gms:play-services-gcm:11.0.4+
# (str) python-for-android branch to use, defaults to master
#p4a.branch = stable
+3 -3
View File
@@ -86,13 +86,13 @@ fullscreen = 0
#android.presplash_color = #FFFFFF
# (list) Permissions
android.permissions = INTERNET,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
android.permissions = ACCESS_NETWORK_STATE,BLUETOOTH,INTERNET,READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
# (int) Android API to use
android.api = 23
# (int) Minimum API required
android.minapi = 16
android.minapi = 21
# (int) Android SDK version to use
android.sdk = 23
@@ -148,7 +148,7 @@ android.react_src = ./app
# (list) Gradle dependencies to add (currently works only with sdl2_gradle
# bootstrap)
android.gradle_dependencies = com.android.support:appcompat-v7:23.4.0, com.facebook.react:react-native:+
android.gradle_dependencies = com.android.support:appcompat-v7:23.4.0, com.facebook.react:react-native:+, com.mixpanel.android:mixpanel-android:5+, com.google.android.gms:play-services-gcm:11.0.4+
# (str) python-for-android branch to use, defaults to master
#p4a.branch = stable
@@ -92,7 +92,9 @@
{{- args.intent_filters -}}
{%- endif -%}
</activity>
<receiver android:name="io.lbry.browser.receivers.NotificationDeletedReceiver" />
{% if args.launcher %}
<activity android:name="org.kivy.android.launcher.ProjectChooser"
android:icon="@drawable/icon"
+47 -16
View File
@@ -47,6 +47,8 @@ class Context(object):
symlink_java_src = False # If True, will symlink instead of copying during build
java_build_tool = 'auto'
@property
def packages_path(self):
'''Where packages are downloaded before being unpacked'''
@@ -158,7 +160,8 @@ class Context(object):
self._ndk_dir = value
def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
user_android_api, user_ndk_ver):
user_android_api, user_android_min_api,
user_ndk_ver):
'''Checks that build dependencies exist and sets internal variables
for the Android SDK etc.
@@ -171,8 +174,6 @@ class Context(object):
if self._build_env_prepared:
return
# AND: This needs revamping to carefully check each dependency
# in turn
ok = True
# Work out where the Android SDK is
@@ -184,7 +185,7 @@ class Context(object):
if sdk_dir is None: # This seems used more conventionally
sdk_dir = environ.get('ANDROID_HOME', None)
if sdk_dir is None: # Checks in the buildozer SDK dir, useful
# # for debug tests of p4a
# for debug tests of p4a
possible_dirs = glob.glob(expanduser(join(
'~', '.buildozer', 'android', 'platform', 'android-sdk-*')))
possible_dirs = [d for d in possible_dirs if not
@@ -226,6 +227,30 @@ class Context(object):
error('You probably want to build with --arch=armeabi-v7a instead')
exit(1)
# try to determinate min_api
android_min_api = None
if user_android_min_api:
android_min_api = user_android_min_api
if android_min_api is not None:
info('Getting Minimum Android API version from user argument')
if android_min_api is None:
android_min_api = environ.get("ANDROIDMINAPI", None)
if android_min_api is not None:
info('Found Android minimum api in $ANDROIDMINAPI')
if android_min_api is None:
info('Minimum Android API was not set, using current Android API '
'{}'.format(android_api))
android_min_api = android_api
android_min_api = int(android_min_api)
self.android_min_api = android_min_api
info("Requested API {} (minimum {})".format(
self.android_api, self.android_min_api))
if self.android_min_api > android_api:
error('Android minimum api cannot be higher than Android api')
exit(1)
if exists(join(sdk_dir, 'tools', 'bin', 'avdmanager')):
avdmanager = sh.Command(join(sdk_dir, 'tools', 'bin', 'avdmanager'))
targets = avdmanager('list', 'target').stdout.decode('utf-8').split('\n')
@@ -235,6 +260,7 @@ class Context(object):
else:
error('Could not find `android` or `sdkmanager` binaries in '
'Android SDK. Exiting.')
exit(1)
apis = [s for s in targets if re.match(r'^ *API level: ', s)]
apis = [re.findall(r'[0-9]+', s) for s in apis]
apis = [int(s[0]) for s in apis if s]
@@ -323,8 +349,9 @@ class Context(object):
warning('If the NDK dir result is correct, you don\'t '
'need to manually set the NDK ver.')
if ndk_ver is None:
warning('Android NDK version could not be found, exiting.')
exit(1)
warning('Android NDK version could not be found. This probably'
'won\'t cause any problems, but if necessary you can'
'set it with `--ndk-version=...`.')
self.ndk_ver = ndk_ver
info('Using {} NDK {}'.format(self.ndk.capitalize(), self.ndk_ver))
@@ -359,7 +386,7 @@ class Context(object):
ok = False
warning("Missing requirement: cython is not installed")
# AND: need to change if supporting multiple archs at once
# This would need to be changed if supporting multiarch APKs
arch = self.archs[0]
platform_dir = arch.platform_dir
toolchain_prefix = arch.toolchain_prefix
@@ -367,7 +394,7 @@ class Context(object):
self.ndk_platform = join(
self.ndk_dir,
'platforms',
'android-{}'.format(self.android_api),
'android-{}'.format(self.android_min_api),
platform_dir)
if not exists(self.ndk_platform):
warning('ndk_platform doesn\'t exist: {}'.format(
@@ -496,7 +523,7 @@ class Context(object):
dir.
'''
# AND: This *must* be replaced with something more general in
# This needs to be replaced with something more general in
# order to support multiple python versions and/or multiple
# archs.
if self.python_recipe.from_crystax:
@@ -575,7 +602,6 @@ def build_recipes(build_order, python_modules, ctx):
.format(recipe.name))
# 4) biglink everything
# AND: Should make this optional
info_main('# Biglinking object files')
if not ctx.python_recipe or not ctx.python_recipe.from_crystax:
biglink(ctx, arch)
@@ -666,12 +692,17 @@ def biglink(ctx, arch):
info('target {}'.format(join(ctx.get_libs_dir(arch.arch),
'libpymodules.so')))
do_biglink = copylibs_function if ctx.copy_libs else biglink_function
do_biglink(
join(ctx.get_libs_dir(arch.arch), 'libpymodules.so'),
obj_dir.split(' '),
extra_link_dirs=[join(ctx.bootstrap.build_dir,
'obj', 'local', arch.arch)],
env=env)
# Move to the directory containing crtstart_so.o and crtend_so.o
# This is necessary with newer NDKs? A gcc bug?
with current_directory(join(ctx.ndk_platform, 'usr', 'lib')):
do_biglink(
join(ctx.get_libs_dir(arch.arch), 'libpymodules.so'),
obj_dir.split(' '),
extra_link_dirs=[join(ctx.bootstrap.build_dir,
'obj', 'local', arch.arch),
os.path.abspath('.')],
env=env)
def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
+5 -6
View File
@@ -30,31 +30,31 @@ def is_arch(xarch):
def is_api_gt(apiver):
def is_x(recipe, **kwargs):
return recipe.ctx.android_api > apiver
return recipe.ctx.android_min_api > apiver
return is_x
def is_api_gte(apiver):
def is_x(recipe, **kwargs):
return recipe.ctx.android_api >= apiver
return recipe.ctx.android_min_api >= apiver
return is_x
def is_api_lt(apiver):
def is_x(recipe, **kwargs):
return recipe.ctx.android_api < apiver
return recipe.ctx.android_min_api < apiver
return is_x
def is_api_lte(apiver):
def is_x(recipe, **kwargs):
return recipe.ctx.android_api <= apiver
return recipe.ctx.android_min_api <= apiver
return is_x
def is_api(apiver):
def is_x(recipe, **kwargs):
return recipe.ctx.android_api == apiver
return recipe.ctx.android_min_api == apiver
return is_x
@@ -68,4 +68,3 @@ def is_ndk(ndk):
def is_x(recipe, **kwargs):
return recipe.ctx.ndk == ndk
return is_x
+1 -1
View File
@@ -931,7 +931,7 @@ class CppCompiledComponentsPythonRecipe(CompiledComponentsPythonRecipe):
)
env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
env['CFLAGS'] += " -I{pyroot}/include/python2.7 " \
" -I{ctx.ndk_dir}/platforms/android-{ctx.android_api}/arch-{arch_noeabi}/usr/include" \
" -I{ctx.ndk_dir}/platforms/android-{ctx.android_min_api}/arch-{arch_noeabi}/usr/include" \
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/include" \
" -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/include".format(**keys)
env['CXXFLAGS'] = env['CFLAGS'] + ' -frtti -fexceptions'
+7
View File
@@ -141,6 +141,7 @@ def require_prebuilt_dist(func):
ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
user_ndk_dir=self.ndk_dir,
user_android_api=self.android_api,
user_android_min_api=self.android_min_api,
user_ndk_ver=self.ndk_version)
dist = self._dist
if dist.needs_build:
@@ -256,6 +257,9 @@ class ToolchainCL(object):
generic_parser.add_argument(
'--android-api', '--android_api', dest='android_api', default=0, type=int,
help='The Android API level to build against.')
generic_parser.add_argument(
'--android-minapi', '--android_minapi', dest='android_min_api', default=0, type=int,
help='The Minimum Android API level to build against (will be used for all C compilation).')
generic_parser.add_argument(
'--ndk-version', '--ndk_version', dest='ndk_version', default='',
help=('The version of the Android NDK. This is optional, '
@@ -499,6 +503,7 @@ class ToolchainCL(object):
self.sdk_dir = args.sdk_dir
self.ndk_dir = args.ndk_dir
self.android_api = args.android_api
self.android_min_api = args.android_min_api
self.ndk_version = args.ndk_version
self.ctx.symlink_java_src = args.symlink_java_src
self.ctx.java_build_tool = args.java_build_tool
@@ -904,6 +909,7 @@ class ToolchainCL(object):
ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
user_ndk_dir=self.ndk_dir,
user_android_api=self.android_api,
user_android_min_api=self.android_min_api,
user_ndk_ver=self.ndk_version)
android = sh.Command(join(ctx.sdk_dir, 'tools', args.tool))
output = android(
@@ -931,6 +937,7 @@ class ToolchainCL(object):
ctx.prepare_build_environment(user_sdk_dir=self.sdk_dir,
user_ndk_dir=self.ndk_dir,
user_android_api=self.android_api,
user_android_min_api=self.android_min_api,
user_ndk_ver=self.ndk_version)
if platform in ('win32', 'cygwin'):
adb = sh.Command(join(ctx.sdk_dir, 'platform-tools', 'adb.exe'))
Executable
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
cd app
react-native bundle --platform android --dev false --entry-file src/index.js --bundle-output ../src/main/assets/index.android.bundle --assets-dest ../src/main/res/
cd ..
version=$(cat src/main/python/main.py | grep --color=never -oP '([0-9]+\.?)+')
buildozer android release
jarsigner -verbose -sigalg SHA1withRSA \
-digestalg SHA1 \
-keystore ~/.keystores/lbry-android.keystore \
-storepass $KEYSTORE_PASSWORD \
bin/browser-$version-release-unsigned.apk lbry-android \
&& mv bin/browser-$version-release-unsigned.apk bin/browser-$version-release-signed.apk
~/Dev/SDKs/android/build-tools/26.0.2/zipalign -v 4 \
bin/browser-$version-release-signed.apk bin/browser-$version-release.apk \
&& rm bin/browser-$version-release-signed.apk
@@ -34,6 +34,11 @@ public class LbrynetService extends PythonService {
public static LbrynetService serviceInstance;
@Override
public boolean canDisplayNotification() {
return false;
}
@Override
public int startType() {
return START_STICKY;
@@ -6,8 +6,9 @@ import android.app.Activity;
import android.app.ActivityManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.content.Intent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.SharedPreferences;
import android.Manifest;
@@ -23,6 +24,7 @@ import com.facebook.react.ReactInstanceManager;
import com.facebook.react.shell.MainReactPackage;
import io.lbry.browser.reactpackages.LbryReactPackage;
import io.lbry.browser.reactmodules.DownloadManagerModule;
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
@@ -156,7 +158,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
ServiceHelper.stop(this, LbrynetService.class);
}
}
super.onDestroy();
if (mReactInstanceManager != null) {
@@ -1,6 +1,9 @@
package io.lbry.browser.reactmodules;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
@@ -8,27 +11,34 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.receivers.NotificationDeletedReceiver;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Random;
/**
* Created by akinwale on 3/15/18.
*/
public class DownloadManagerModule extends ReactContextBaseJavaModule {
private Context context;
private HashMap<Integer, NotificationCompat.Builder> builders = new HashMap<Integer, NotificationCompat.Builder>();
private HashMap<String, Integer> downloadIdNotificationIdMap = new HashMap<String, Integer>();
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
private static final int MAX_PROGRESS = 100;
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
private static final String GROUP_DOWNLOADS = "io.lbry.browser.GROUP_DOWNLOADS";
public static final String NOTIFICATION_ID_KEY = "io.lbry.browser.notificationId";
public static final int GROUP_ID = 0;
public static boolean groupCreated = false;
public DownloadManagerModule(ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext;
@@ -42,16 +52,47 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
public String getName() {
return "LbryDownloadManager";
}
private void createNotificationGroup() {
if (!groupCreated) {
Intent intent = new Intent(context, NotificationDeletedReceiver.class);
intent.putExtra(NOTIFICATION_ID_KEY, GROUP_ID);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, GROUP_ID, intent, 0);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle("Active downloads")
.setContentText("Active downloads")
.setSmallIcon(R.drawable.ic_file_download_black_24dp)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setGroup(GROUP_DOWNLOADS)
.setGroupSummary(true)
.setDeleteIntent(pendingIntent);
notificationManager.notify(GROUP_ID, builder.build());
groupCreated = true;
}
}
private PendingIntent getLaunchPendingIntent() {
Intent launchIntent = new Intent(context, MainActivity.class);
launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, launchIntent, 0);
return intent;
}
@ReactMethod
public void startDownload(String id, String fileName) {
createNotificationGroup();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle(String.format("Downloading %s...", fileName))
.setSmallIcon(R.drawable.ic_file_download_black_24dp)
.setPriority(NotificationCompat.PRIORITY_LOW);
builder.setProgress(MAX_PROGRESS, 0, false);
builder.setContentIntent(getLaunchPendingIntent())
.setContentTitle(String.format("Downloading %s...", fileName))
.setGroup(GROUP_DOWNLOADS)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setProgress(MAX_PROGRESS, 0, false)
.setSmallIcon(R.drawable.ic_file_download_black_24dp);
int notificationId = generateNotificationId();
downloadIdNotificationIdMap.put(id, notificationId);
@@ -71,16 +112,17 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
return;
}
createNotificationGroup();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationCompat.Builder builder = builders.get(notificationId);
builder.setProgress(MAX_PROGRESS, new Double(progress).intValue(), false);
builder.setContentText(String.format("%.0f%% (%s / %s)", progress, formatBytes(writtenBytes), formatBytes(totalBytes)));
builder.setOngoing(true);
builder.setContentIntent(getLaunchPendingIntent())
.setContentText(String.format("%.0f%% (%s / %s)", progress, formatBytes(writtenBytes), formatBytes(totalBytes)))
.setGroup(GROUP_DOWNLOADS)
.setProgress(MAX_PROGRESS, new Double(progress).intValue(), false);
notificationManager.notify(notificationId, builder.build());
if (progress == MAX_PROGRESS) {
builder.setContentTitle(String.format("Downloaded %s.", fileName));
builder.setOngoing(false);
downloadIdNotificationIdMap.remove(id);
builders.remove(notificationId);
}
@@ -99,11 +141,15 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationCompat.Builder builder = builders.get(notificationId);
builder.setOngoing(false);
notificationManager.cancel(notificationId);
downloadIdNotificationIdMap.remove(id);
builders.remove(notificationId);
if (builders.values().size() == 0) {
notificationManager.cancel(GROUP_ID);
groupCreated = false;
}
}
private String formatBytes(double bytes)
@@ -0,0 +1,54 @@
package io.lbry.browser.reactmodules;
import android.content.Context;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.mixpanel.android.mpmetrics.MixpanelAPI;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONObject;
import org.json.JSONException;
public class MixpanelModule extends ReactContextBaseJavaModule {
private static final String MIXPANEL_TOKEN = "93b81fb957cb0ddcd3198c10853a6a95";
private Context context;
private MixpanelAPI mixpanel;
public MixpanelModule(ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext;
this.mixpanel = MixpanelAPI.getInstance(this.context, MIXPANEL_TOKEN);
}
@Override
public String getName() {
return "Mixpanel";
}
@ReactMethod
public void track(String name, ReadableMap payload) {
JSONObject props = new JSONObject();
try {
if (payload != null) {
HashMap<String, Object> payloadMap = payload.toHashMap();
for (Map.Entry<String, Object> entry : payloadMap.entrySet()) {
props.put(entry.getKey(), entry.getValue());
}
}
} catch (JSONException e) {
// Cannot use props. Stick with empty props.
}
if (mixpanel != null) {
mixpanel.track(name, props);
}
}
}
@@ -0,0 +1,38 @@
package io.lbry.browser.reactmodules;
import android.content.Context;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
public class VersionInfoModule extends ReactContextBaseJavaModule {
private Context context;
public VersionInfoModule(ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext;
}
@Override
public String getName() {
return "VersionInfo";
}
@ReactMethod
public void getAppVersion(final Promise promise) {
PackageManager packageManager = this.context.getPackageManager();
String packageName = this.context.getPackageName();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
promise.resolve(packageInfo.versionName);
} catch (PackageManager.NameNotFoundException e) {
// normally shouldn't happen
promise.resolve("Unknown");
}
}
}
@@ -7,7 +7,9 @@ import com.facebook.react.uimanager.ViewManager;
import io.lbry.browser.reactmodules.DaemonServiceControlModule;
import io.lbry.browser.reactmodules.DownloadManagerModule;
import io.lbry.browser.reactmodules.MixpanelModule;
import io.lbry.browser.reactmodules.ScreenOrientationModule;
import io.lbry.browser.reactmodules.VersionInfoModule;
import java.util.ArrayList;
import java.util.Collections;
@@ -25,7 +27,9 @@ public class LbryReactPackage implements ReactPackage {
modules.add(new DaemonServiceControlModule(reactContext));
modules.add(new DownloadManagerModule(reactContext));
modules.add(new MixpanelModule(reactContext));
modules.add(new ScreenOrientationModule(reactContext));
modules.add(new VersionInfoModule(reactContext));
return modules;
}
@@ -0,0 +1,17 @@
package io.lbry.browser.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import io.lbry.browser.reactmodules.DownloadManagerModule;
public class NotificationDeletedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
int notificationId = intent.getExtras().getInt(DownloadManagerModule.NOTIFICATION_ID_KEY);
if (DownloadManagerModule.GROUP_ID == notificationId) {
DownloadManagerModule.groupCreated = false;
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
__version__ = "0.1.1"
__version__ = "0.1.3"
class ServiceApp(App):
def build(self):