Compare commits

...
50 Commits
Author SHA1 Message Date
Akinwale Ariwodola 191bc33fa3 bumpversion 0.1.7 --> 0.1.8 2018-06-11 19:24:26 +01:00
Akinwale Ariwodola 31168d9ed8 Merge pull request #166 from lbryio/first-run-improvements
implement extendable first run experience starting with welcome page
2018-06-11 04:41:55 +01:00
Akinwale Ariwodola 468c41c526 implement extendable first run experience starting with welcome page 2018-06-08 09:13:45 +01:00
Akinwale Ariwodola bc684b6ae3 Merge pull request #158 from lbryio/about-page-text
add a paragraph and links to the About page
2018-06-08 06:30:10 +01:00
Akinwale Ariwodola 399ec8d108 Make channel names displayed on file items and the file page touchable (#165) 2018-06-07 06:57:41 +01:00
Akinwale Ariwodola 1820710f06 Merge pull request #160 from lbryio/linkify-description
make links in file descriptions clickable
2018-06-07 05:00:33 +01:00
Akinwale Ariwodola 51d86148e8 Merge pull request #164 from lbryio/navigation-tweaks
set the unique navigation keys for the file pages to the URIs.
2018-06-06 09:29:24 +01:00
Akinwale Ariwodola e8f973531b set the unique navigation keys for the file pages to the URIs. 2018-06-06 09:25:51 +01:00
Akinwale Ariwodola 4a01cf0608 Merge pull request #162 from lbryio/trending-page
add trending page
2018-06-06 01:25:16 +01:00
Akinwale Ariwodola 929a057e1e add trending page 2018-06-05 19:52:10 +01:00
Akinwale Ariwodola d24a18023d make links in file descriptions clickable 2018-06-05 19:03:40 +01:00
Akinwale Ariwodola 4d8085a0db add a paragraph and links to the About page 2018-06-05 15:53:10 +01:00
Akinwale Ariwodola 8c3ca2161d Merge pull request #156 from lbryio/search-result-urls
Add URI to search result items. Update omnibar URI suggestions display.
2018-06-04 17:34:38 +01:00
Akinwale Ariwodola 26720dead0 Wallet page improvements (#155)
* wallet page send form improvements
* style tweaks for the send form input fields
2018-06-04 17:34:03 +01:00
Akinwale Ariwodola cda7e81485 Merge pull request #157 from lbryio/omnibar-file-suggestion
change icon for URIs linking to actual file claims
2018-06-03 13:53:10 +01:00
Akinwale Ariwodola 0cffb26dfc change icon for URIs linking to actual file claims 2018-06-03 13:51:02 +01:00
Akinwale Ariwodola d21e4aa830 Add URI to search result items. Update omnibar URI suggestions display. 2018-06-03 13:46:43 +01:00
Akinwale Ariwodola 00f4745d46 bumpversion 0.1.6 --> 0.1.7 2018-05-27 22:00:46 +01:00
Akinwale Ariwodola 062e7cef24 Merge pull request #143 from lbryio/fix-uri-bar-errors
blur text input and hide suggestions when the soft keyboard is closed
2018-05-27 21:55:51 +01:00
Akinwale Ariwodola efc710d796 blur text input and hide suggestions when the soft keyboard is closed 2018-05-27 21:48:06 +01:00
Akinwale Ariwodola fd2d20af94 bumpversion 0.1.5 --> 0.1.6 2018-05-26 00:33:37 +01:00
Akinwale Ariwodola 51065d1b57 Merge pull request #142 from lbryio/uri-bar-improvements
Improvements to the UriBar implementation and some navigation tweaks.
2018-05-26 00:32:13 +01:00
Akinwale Ariwodola 6a60ce07e9 Improvements to the UriBar implementation and some navigation tweaks. 2018-05-26 00:20:44 +01:00
Akinwale Ariwodola 7c8f9a6662 Merge pull request #141 from lbryio/image-and-html-file-types
add support for viewing images, HTML and text files in the app
2018-05-25 19:53:33 +01:00
Akinwale Ariwodola ed61f470f7 Implement channel page with just the first page of results (#140) 2018-05-25 19:52:08 +01:00
Akinwale Ariwodola a89d8ac229 add support for viewing images, HTML and text files in the app 2018-05-25 18:39:02 +01:00
akinwale 3c8e7d13e0 enable purchases for paid content (#133) 2018-05-25 08:16:01 +01:00
akinwale 7d2e4c1e8c Handle lbry:// url scheme, and download notification fixes. (#139) 2018-05-25 08:13:05 +01:00
akinwale 4fbf90654e implement direct URI navigation (#134) 2018-05-24 23:47:55 +01:00
Daniel Alejandro Dominguez Diaz 077af85181 Add development information to the documentation (#123)
*
2018-05-23 14:09:57 +01:00
akinwale 1b77a8dd8b Merge pull request #135 from lbryio/navigation-perf
replaced FeaturedCategory with SectionList on discover page to improve performance
2018-05-21 19:02:36 +01:00
akinwale 28071a10b5 Merge pull request #137 from lbryio/debug-check
add debug build checks
2018-05-19 23:37:01 +01:00
Akinwale Ariwodola 1a6e3bf214 add debug build checks 2018-05-19 23:35:43 +01:00
Akinwale Ariwodola 16db19fac7 Increase storage requirement toast display duration 2018-05-19 23:03:03 +01:00
akinwale c533e7832b Merge pull request #136 from lbryio/keep-daemon-running-default
display the correct default value for the keep daemon running option
2018-05-19 21:11:42 +01:00
Akinwale Ariwodola 0cd33ddada display the correct default value for the keep daemon running option 2018-05-19 21:10:27 +01:00
Akinwale Ariwodola 140d405aa9 replaced FeaturedCategory with SectionList on discover page to improve performance 2018-05-19 20:50:09 +01:00
akinwale ceeef6324e Video fullscreen switch (#132)
* file page download progress display and media loading / playback tweaks
* Moved MediaPlayer component to be a child of the top-level view
* hide tracking controls when player controls are hidden in fullscreen mode
2018-05-19 16:11:59 +01:00
akinwale f850be1eca Merge pull request #131 from lbryio/download-progress-video-playing
file page download progress display and media loading / playback tweaks
2018-05-19 15:01:28 +01:00
Daniel Alejandro Dominguez Diaz 28c5b01596 Clear search results after closing search as reported on issue #113 (#124) 2018-05-18 19:13:27 +01:00
Akinwale Ariwodola 59f5b5ede3 file page download progress display and media loading / playback tweaks 2018-05-18 12:00:58 +01:00
akinwale 8db8083e32 Merge pull request #130 from lbryio/selectable-description
add selectable flag for file title, channel name and description
2018-05-18 09:50:18 +01:00
Akinwale Ariwodola a2c3f36065 add selectable flag for file title, channel name and description 2018-05-18 09:49:04 +01:00
Akinwale Ariwodola 0483e67026 Remove postinstall step which is no longer needed in RN 0.55.3. Update react-navigation version. 2018-05-18 08:07:18 +01:00
akinwale 872fafbb50 Merge pull request #129 from lbryio/python-requirements-tweak
* Fix service_identity requirements
* Add certifi for Twisted SSL veriication
2018-05-16 00:55:53 +01:00
Akinwale Ariwodola 4d57d72980 Fix service_identity requirements. Add certifi for Twisted SSL verification. 2018-05-16 00:49:47 +01:00
Akinwale Ariwodola 77f5d5cf05 Updated React Native version to fix startup error. Updated buildozer requirements to match latest lbryio/lbry requirements.txt. 2018-05-15 22:14:08 +01:00
Akinwale Ariwodola 5e6dfb18f7 bumpversion 0.1.4 --> 0.1.5 2018-05-15 19:00:18 +01:00
akinwale fe8b7ec5b3 Fix missing react-native-cli tools for build (#128) 2018-05-15 18:59:04 +01:00
akinwale f6503dc367 Travis tweaks (#122) 2018-05-11 08:09:53 +01:00
74 changed files with 4742 additions and 15535 deletions

No files matched your search

+12 -14
View File
@@ -8,30 +8,28 @@ install:
- export PATH=/usr/bin:$PATH
- sudo dpkg --add-architecture i386
- sudo apt-get -qq update
- sudo apt-get -qq install build-essential ccache git libncurses5:i386 libstdc++6:i386
libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7
python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386
- sudo apt-get -qq install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386
- sudo pip install --upgrade cython==0.25.2 pip setuptools
- wget https://nodejs.org/dist/v8.11.1/node-v8.11.1-linux-x64.tar.xz
- wget -q https://nodejs.org/dist/v8.11.1/node-v8.11.1-linux-x64.tar.xz
- tar -xf node-v8.11.1-linux-x64.tar.xz
- sudo ln -s ~/node-v8.11.1-linux-x64/bin/node /usr/bin/node
- sudo ln -s ~/node-v8.11.1-linux-x64/bin/npm /usr/bin/npm
- sudo ln -s $TRAVIS_BUILD_DIR/node-v8.11.1-linux-x64/bin/node /usr/bin/node
- sudo ln -s $TRAVIS_BUILD_DIR/node-v8.11.1-linux-x64/bin/npm /usr/bin/npm
- git clone https://github.com/lbryio/buildozer.git
- cd app
- npm config set registry="http://registry.npmjs.org/"
- npm install
- sudo npm install -g react-native-cli
- sudo ln -s $TRAVIS_BUILD_DIR/node-v8.11.1-linux-x64/bin/react-native /usr/bin/react-native
- cd ..
- cd buildozer
- sudo python setup.py install
- cd ..
- mv buildozer.spec.travis buildozer.spec
- mkdir -p cd ~/.buildozer/android/platform/
- wget 'https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip'
-P ~/.buildozer/android/platform/
- wget 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P ~/.buildozer/android/platform/
- wget 'https://dl.google.com/android/repository/android-23_r02.zip' -P ~/.buildozer/android/platform/
- wget 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P
~/.buildozer/android/platform/
- wget -q 'https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip' -P ~/.buildozer/android/platform/
- wget -q 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P ~/.buildozer/android/platform/
- wget -q 'https://dl.google.com/android/repository/android-23_r02.zip' -P ~/.buildozer/android/platform/
- wget -q 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P ~/.buildozer/android/platform/
- unzip -qq ~/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip -d ~/.buildozer/android/platform/
- tar -xf ~/.buildozer/android/platform/android-sdk_r23-linux.tgz -C ~/.buildozer/android/platform/
- mv ~/.buildozer/android/platform/android-sdk-linux ~/.buildozer/android/platform/android-sdk-23
@@ -44,9 +42,9 @@ install:
- echo $'\nd56f5187479451eabf01fb78af6dfcb131a6481e' > ~/.buildozer/android/platform/android-sdk-23/licenses/android-sdk-license
script:
- "./release.sh | grep -Fv -e 'working:' -e 'copy' -e 'Compiling' --line-buffered"
- cp bin/*.apk /dev/null
- cp $TRAVIS_BUILD_DIR/bin/*.apk /dev/null
before_deploy:
- cd bin
- cd $TRAVIS_BUILD_DIR/bin
- export BUILD_VERSION=$(cat ../src/main/python/main.py | grep --color=never -oP '([0-9]+\.?)+')
- cp browser-$BUILD_VERSION-release.apk latest.apk
deploy:
+10
View File
@@ -64,3 +64,13 @@ Run `npm i` in the `lbry-android/app` folder to install the necessary modules re
Run `./build.sh` in `lbry-android` to build the APK. The output can be found in the `bin` subdirectory.
To build and deploy, you can run `./deploy.sh`. This requires a connected device or running Android emulator.
#### Development
If you already installed `Android SDK` and `adb`
* Run `adb reverse tcp:8081 tcp:8081`
* Then go to the `lbry-android/app` folder and run `npm start`
Note: You need to have your device connected with USB debugging.
Once the bundler is ready, run the LBRY Browser app on your device and then shake the device violently until you see the React Native dev menu. You can enable "Live Reloading" and "Hot Reloading" from this menu, so any changes you make to the React Native code will be visible as you save. This will only reload React Native Javascript files. Native Java code needs to be redeployed by running the command `./deploy.sh`
+2997 -2167
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -3,17 +3,17 @@
"version": "0.0.1",
"private": "true",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"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"
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"lbry-redux": "lbryio/lbry-redux",
"moment": "^2.22.1",
"react": "16.2.0",
"react-native": "0.52.0",
"react-native": "0.55.3",
"react-native-image-zoom-viewer": "^2.2.5",
"react-native-vector-icons": "^4.5.0",
"react-native-video": "2.0.0",
"react-navigation": "^1.0.3",
"react-navigation": "^1.5.12",
"react-navigation-redux-helpers": "^1.0.1",
"react-redux": "^5.0.3",
"redux": "^3.6.0",
File diff suppressed because it is too large. Load diff
+49 -15
View File
@@ -2,7 +2,9 @@ import React from 'react';
import AboutPage from '../page/about';
import DiscoverPage from '../page/discover';
import FilePage from '../page/file';
import FirstRunScreen from '../page/firstRun';
import SearchPage from '../page/search';
import TrendingPage from '../page/trending';
import SettingsPage from '../page/settings';
import SplashScreen from '../page/splash';
import TransactionHistoryPage from '../page/transactionHistory';
@@ -20,6 +22,7 @@ import {
AppState,
AsyncStorage,
BackHandler,
Linking,
NativeModules,
TextInput,
ToastAndroid
@@ -29,6 +32,7 @@ import { makeSelectClientSetting } from '../redux/selectors/settings';
import Feather from 'react-native-vector-icons/Feather';
import discoverStyle from '../styles/discover';
import searchStyle from '../styles/search';
import SearchRightHeaderIcon from "../component/searchRightHeaderIcon";
const discoverStack = StackNavigator({
Discover: {
@@ -36,7 +40,6 @@ const discoverStack = StackNavigator({
navigationOptions: ({ navigation }) => ({
title: 'Discover',
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: {
@@ -49,22 +52,29 @@ const discoverStack = StackNavigator({
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())} />
drawerLockMode: 'locked-closed'
})
}
}, {
headerMode: 'screen',
});
const trendingStack = StackNavigator({
Trending: {
screen: TrendingPage,
navigationOptions: ({ navigation }) => ({
title: 'Trending',
headerLeft: <Feather name="menu" size={24} style={discoverStyle.drawerHamburger} onPress={() => navigation.navigate('DrawerOpen')} />,
})
}
});
const walletStack = StackNavigator({
Wallet: {
screen: WalletPage,
navigationOptions: ({ navigation }) => ({
title: 'Wallet',
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')} />
})
},
TransactionHistory: {
@@ -80,6 +90,7 @@ const walletStack = StackNavigator({
const drawer = DrawerNavigator({
DiscoverStack: { screen: discoverStack },
TrendingStack: { screen: trendingStack },
WalletStack: { screen: walletStack },
Settings: { screen: SettingsPage, navigationOptions: { drawerLockMode: 'locked-closed' } },
About: { screen: AboutPage, navigationOptions: { drawerLockMode: 'locked-closed' } }
@@ -89,6 +100,12 @@ const drawer = DrawerNavigator({
});
export const AppNavigator = new StackNavigator({
FirstRun: {
screen: FirstRunScreen,
navigationOptions: {
drawerLockMode: 'locked-closed'
}
},
Splash: {
screen: SplashScreen,
navigationOptions: {
@@ -104,11 +121,11 @@ export const AppNavigator = new StackNavigator({
class AppWithNavigationState extends React.Component {
static supportedDisplayTypes = ['toast'];
componentWillMount() {
AppState.addEventListener('change', this._handleAppStateChange);
BackHandler.addEventListener('hardwareBackPress', function() {
const { dispatch, navigation, nav } = this.props;
const { dispatch, nav } = this.props;
// There should be a better way to check this
if (nav.routes.length > 0) {
const subRoutes = nav.routes[0].routes[0].routes;
@@ -119,7 +136,7 @@ class AppWithNavigationState extends React.Component {
return true;
}
if (nav.routes[0].routeName === 'Main') {
if (nav.routes[0].routes[0].routes[0].index > 0) {
if (nav.routes[0].routes[0].routes[0].index > 0) {
dispatch(NavigationActions.back());
return true;
}
@@ -128,12 +145,17 @@ class AppWithNavigationState extends React.Component {
return false;
}.bind(this));
}
componentDidMount() {
Linking.addEventListener('url', this._handleUrl);
}
componentWillUnmount() {
AppState.removeEventListener('change', this._handleAppStateChange);
BackHandler.removeEventListener('hardwareBackPress');
Linking.removeEventListener('url', this._handleUrl);
}
componentWillUpdate(nextProps) {
const { dispatch } = this.props;
const { notification } = nextProps;
@@ -151,15 +173,15 @@ class AppWithNavigationState extends React.Component {
} else if (AppWithNavigationState.supportedDisplayTypes.indexOf(displayType) > -1) {
currentDisplayType = displayType;
}
if ('toast' === currentDisplayType) {
ToastAndroid.show(message, ToastAndroid.SHORT);
}
dispatch(doHideNotification());
}
}
_handleAppStateChange = (nextAppState) => {
// Check if the app was suspended
if (AppState.currentState && AppState.currentState.match(/inactive|background/)) {
@@ -172,7 +194,19 @@ class AppWithNavigationState extends React.Component {
});
}
}
_handleUrl = (evt) => {
const { dispatch } = this.props;
if (evt.url) {
const navigateAction = NavigationActions.navigate({
routeName: 'File',
key: evt.url,
params: { uri: evt.url }
});
dispatch(navigateAction);
}
}
render() {
const { dispatch, nav } = this.props;
return (
@@ -193,5 +227,5 @@ const mapStateToProps = state => ({
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state)
});
export default connect(mapStateToProps)(AppWithNavigationState);
@@ -1,7 +0,0 @@
import { connect } from 'react-redux';
import FeaturedCategory from './view';
const select = state => ({});
const perform = dispatch => ({});
export default connect(select, perform)(FeaturedCategory);
@@ -1,27 +0,0 @@
import React from 'react';
import { Text, View } from 'react-native';
import { normalizeURI } from 'lbry-redux';
import FileItem from '../fileItem';
import discoverStyle from '../../styles/discover';
class FeaturedCategory extends React.PureComponent {
render() {
const { category, names, categoryLink, navigation } = this.props;
return (
<View>
<Text style={discoverStyle.categoryName}>{category}</Text>
{names &&
names.map(name => (
<FileItem
style={discoverStyle.fileItem}
key={name}
uri={normalizeURI(name)}
navigation={navigation} />
))}
</View>
);
}
}
export default FeaturedCategory;
@@ -1,5 +1,6 @@
import { connect } from 'react-redux';
import {
doFetchCostInfoForUri,
makeSelectFileInfoForUri,
makeSelectDownloadingForUri,
makeSelectLoadingForUri,
@@ -17,7 +18,8 @@ const select = (state, props) => ({
const perform = dispatch => ({
purchaseUri: uri => dispatch(doPurchaseUri(uri)),
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint))
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
});
export default connect(select, perform)(FileDownloadButton);
+10 -7
View File
@@ -3,6 +3,13 @@ import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
import fileDownloadButtonStyle from '../../styles/fileDownloadButton';
class FileDownloadButton extends React.PureComponent {
componentDidMount() {
const { costInfo, fetchCostInfo, uri } = this.props;
if (costInfo === undefined) {
fetchCostInfo(uri);
}
}
componentWillReceiveProps(nextProps) {
//this.checkAvailability(nextProps.uri);
this.restartDownload(nextProps);
@@ -32,13 +39,9 @@ class FileDownloadButton extends React.PureComponent {
loading,
doPause,
style,
openFile
} = this.props;
const openFile = () => {
//openInShell(fileInfo.download_path);
//doPause();
};
if (loading || downloading) {
const progress =
fileInfo && fileInfo.written_bytes ? fileInfo.written_bytes / fileInfo.total_bytes * 100 : 0,
@@ -54,7 +57,7 @@ class FileDownloadButton extends React.PureComponent {
if (!costInfo) {
return (
<View style={[style, fileDownloadButtonStyle.container]}>
<Text>Fetching cost info...</Text>
<Text style={fileDownloadButtonStyle.text}>Fetching cost info...</Text>
</View>
);
}
@@ -70,7 +73,7 @@ class FileDownloadButton extends React.PureComponent {
);
} else if (fileInfo && fileInfo.download_path) {
return (
<TouchableOpacity style={[style, fileDownloadButtonStyle.container]} onPress={() => openFile()}>
<TouchableOpacity style={[style, fileDownloadButtonStyle.container]} onPress={openFile}>
<Text style={fileDownloadButtonStyle.text}>Open</Text>
</TouchableOpacity>
);
+6 -2
View File
@@ -4,6 +4,7 @@ import { NavigationActions } from 'react-navigation';
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
import FileItemMedia from '../fileItemMedia';
import FilePrice from '../filePrice';
import Link from '../link';
import NsfwOverlay from '../nsfwOverlay';
import discoverStyle from '../../styles/discover';
@@ -61,14 +62,17 @@ class FileItem extends React.PureComponent {
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('Discover Tap', { Uri: uri });
}
navigation.navigate('File', { uri: uri });
navigation.navigate({ routeName: 'File', key: uri, params: { uri } });
}
}>
<FileItemMedia title={title} thumbnail={thumbnail} blurRadius={obscureNsfw ? 15 : 0} resizeMode="cover" />
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
<Text style={discoverStyle.fileItemName}>{title}</Text>
{channelName &&
<Text style={discoverStyle.channelName}>{channelName}</Text>}
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
const channelUri = normalizeURI(channelName);
navigation.navigate({ routeName: 'File', key: channelUri, params: { uri: channelUri }});
}} />}
</TouchableOpacity>
{obscureNsfw && <NsfwOverlay onPress={() => navigation.navigate('Settings')} />}
</View>
+11
View File
@@ -0,0 +1,11 @@
import { connect } from 'react-redux';
import FileList from './view';
import { selectClaimsById } from 'lbry-redux';
const select = state => ({
claimsById: selectClaimsById(state),
});
const perform = dispatch => ({});
export default connect(select, perform)(FileList);
+184
View File
@@ -0,0 +1,184 @@
// @flow
import * as React from 'react';
import { buildURI } from 'lbry-redux';
import { FlatList } from 'react-native';
import FileItem from '../fileItem';
import discoverStyle from '../../styles/discover';
// In the future, all Flow types need to be specified in a common source (lbry-redux, perhaps?)
type FileInfo = {
name: string,
channelName: ?string,
pending?: boolean,
channel_claim_id: string,
value?: {
publisherSignature: {
certificateId: string,
},
},
metadata: {
publisherSignature: {
certificateId: string,
},
},
};
type Props = {
hideFilter: boolean,
sortByHeight?: boolean,
claimsById: Array<{}>,
fileInfos: Array<FileInfo>,
checkPending?: boolean,
};
type State = {
sortBy: string,
};
class FileList extends React.PureComponent<Props, State> {
static defaultProps = {
hideFilter: false,
};
constructor(props: Props) {
super(props);
this.state = {
sortBy: 'dateNew',
};
(this: any).handleSortChanged = this.handleSortChanged.bind(this);
this.sortFunctions = {
dateNew: fileInfos =>
this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
if (fileInfo1.pending) {
return -1;
}
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 0;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 0;
if (height1 > height2) {
return -1;
} else if (height1 < height2) {
return 1;
}
return 0;
})
: [...fileInfos].reverse(),
dateOld: fileInfos =>
this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 999999;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 999999;
if (height1 < height2) {
return -1;
} else if (height1 > height2) {
return 1;
}
return 0;
})
: fileInfos,
title: fileInfos =>
fileInfos.slice().sort((fileInfo1, fileInfo2) => {
const getFileTitle = fileInfo => {
const { value, metadata, name, claim_name: claimName } = fileInfo;
if (metadata) {
// downloaded claim
return metadata.title || claimName;
} else if (value) {
// published claim
const { title } = value.stream.metadata;
return title || name;
}
// Invalid claim
return '';
};
const title1 = getFileTitle(fileInfo1).toLowerCase();
const title2 = getFileTitle(fileInfo2).toLowerCase();
if (title1 < title2) {
return -1;
} else if (title1 > title2) {
return 1;
}
return 0;
}),
filename: fileInfos =>
fileInfos.slice().sort(({ file_name: fileName1 }, { file_name: fileName2 }) => {
const fileName1Lower = fileName1.toLowerCase();
const fileName2Lower = fileName2.toLowerCase();
if (fileName1Lower < fileName2Lower) {
return -1;
} else if (fileName2Lower > fileName1Lower) {
return 1;
}
return 0;
}),
};
}
getChannelSignature = (fileInfo: FileInfo) => {
if (fileInfo.pending) {
return undefined;
}
if (fileInfo.value) {
return fileInfo.value.publisherSignature.certificateId;
}
return fileInfo.channel_claim_id;
};
handleSortChanged(event: SyntheticInputEvent<*>) {
this.setState({
sortBy: event.target.value,
});
}
sortFunctions: {};
render() {
const { fileInfos, hideFilter, checkPending, navigation, style } = this.props;
const { sortBy } = this.state;
const items = [];
if (!fileInfos) {
return null;
}
this.sortFunctions[sortBy](fileInfos).forEach(fileInfo => {
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = fileInfo;
const uriParams = {};
// This is unfortunate
// https://github.com/lbryio/lbry/issues/1159
const name = claimName || claimNameDownloaded;
uriParams.contentName = name;
uriParams.claimId = claimId;
const uri = buildURI(uriParams);
items.push(uri);
});
return (
<FlatList
style={style}
data={items}
keyExtractor={(item, index) => item}
renderItem={({item}) => (
<FileItem style={discoverStyle.fileItem}
uri={item}
navigation={navigation} />
)} />
);
}
}
export default FileList;
+9 -7
View File
@@ -23,16 +23,18 @@ export default class Link extends React.PureComponent {
} = this.props;
let styles = [];
if (style.length) {
styles = styles.concat(style);
} else {
styles.push(style);
if (style) {
if (style.length) {
styles = styles.concat(style);
} else {
styles.push(style);
}
}
return (
<TouchableOpacity onPress={onPress ? onPress : this.handlePress}>
<Text style={styles}>{text}</Text>
</TouchableOpacity>
<Text style={styles} onPress={onPress ? onPress : this.handlePress}>
{text}
</Text>
);
}
};
+58 -24
View File
@@ -20,23 +20,30 @@ class MediaPlayer extends React.PureComponent {
seekerWidth = 0;
trackingOffset = 0;
tracking = null;
video = null;
state = {
rate: 1,
volume: 1,
muted: false,
resizeMode: 'stretch',
duration: 0.0,
currentTime: 0.0,
paused: true,
fullscreenMode: false,
areControlsVisible: true,
controlsTimeout: -1,
seekerOffset: 0,
seekerPosition: 0,
firstPlay: true
};
constructor(props) {
super(props);
this.state = {
rate: 1,
volume: 1,
muted: false,
resizeMode: 'stretch',
duration: 0.0,
currentTime: 0.0,
paused: true,
fullscreenMode: false,
areControlsVisible: true,
controlsTimeout: -1,
seekerOffset: 0,
seekerPosition: 0,
firstPlay: true
};
}
formatTime(time) {
let str = '';
@@ -144,10 +151,11 @@ class MediaPlayer extends React.PureComponent {
}
checkSeekerPosition(val = 0) {
if (val < 0) {
val = 0;
} else if (val >= this.seekerWidth) {
return this.seekerWidth;
const offset = this.getTrackingOffset();
if (val < offset) {
val = offset;
} else if (val >= (offset + this.seekerWidth)) {
return offset + this.seekerWidth;
}
return val;
@@ -190,11 +198,18 @@ class MediaPlayer extends React.PureComponent {
});
}
getTrackingOffset() {
return this.state.fullscreenMode ? this.trackingOffset : 0;
}
getCurrentTimeForSeekerPosition() {
return this.state.duration * (this.state.seekerPosition / this.seekerWidth);
}
calculateSeekerPosition() {
if (this.state.fullscreenMode) {
return this.getTrackingOffset() + (this.seekerWidth * this.getCurrentTimePercentage());
}
return this.seekerWidth * this.getCurrentTimePercentage();
}
@@ -209,6 +224,10 @@ class MediaPlayer extends React.PureComponent {
this.initSeeker();
}
componentDidMount() {
}
componentWillUnmount() {
this.clearControlsTimeout();
this.setState({ paused: true, fullscreenMode: false });
@@ -243,12 +262,23 @@ class MediaPlayer extends React.PureComponent {
}
render() {
const { backgroundPlayEnabled, fileInfo, thumbnail, style, fullScreenStyle } = this.props;
const { backgroundPlayEnabled, fileInfo, thumbnail, style } = this.props;
const flexCompleted = this.getCurrentTimePercentage() * 100;
const flexRemaining = (1 - this.getCurrentTimePercentage()) * 100;
let styles = [this.state.fullscreenMode ? mediaPlayerStyle.fullscreenContainer : mediaPlayerStyle.container];
if (style) {
if (style.length) {
styles = styles.concat(style);
} else {
styles.push(style);
}
}
const trackingStyle = [mediaPlayerStyle.trackingControls, this.state.fullscreenMode ?
mediaPlayerStyle.fullscreenTrackingControls : mediaPlayerStyle.containedTrackingControls];
return (
<View style={[style, mediaPlayerStyle.container]}>
<View style={styles}>
<Video source={{ uri: 'file:///' + fileInfo.download_path }}
ref={(ref: Video) => { this.video = ref }}
resizeMode={this.state.resizeMode}
@@ -266,12 +296,16 @@ class MediaPlayer extends React.PureComponent {
{this.renderPlayerControls()}
</TouchableOpacity>
<View style={mediaPlayerStyle.trackingControls}>
<View style={mediaPlayerStyle.progress} onLayout={(evt) => this.seekerWidth = evt.nativeEvent.layout.width}>
{(!this.state.fullscreenMode || (this.state.fullscreenMode && this.state.areControlsVisible)) &&
<View style={trackingStyle} onLayout={(evt) => {
this.trackingOffset = evt.nativeEvent.layout.x;
this.seekerWidth = evt.nativeEvent.layout.width;
}}>
<View style={mediaPlayerStyle.progress}>
<View style={[mediaPlayerStyle.innerProgressCompleted, { flex: flexCompleted }]} />
<View style={[mediaPlayerStyle.innerProgressRemaining, { flex: flexRemaining }]} />
</View>
</View>
</View>}
{this.state.areControlsVisible &&
<View style={[mediaPlayerStyle.seekerHandle, { left: this.state.seekerPosition }]} { ...this.seekResponder.panHandlers }>
+9 -2
View File
@@ -1,6 +1,7 @@
import React from 'react';
import { normalizeURI, parseURI } from 'lbry-redux';
import { Text, TouchableOpacity, View } from 'react-native';
import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native';
import Colors from '../../styles/colors';
import FileItemMedia from '../fileItemMedia';
import NsfwOverlay from '../../component/nsfwOverlay';
import searchStyle from '../../styles/search';
@@ -39,7 +40,13 @@ class SearchResultItem extends React.PureComponent {
thumbnail={metadata ? metadata.thumbnail : null} />
</View>
<View style={searchStyle.detailsContainer}>
{isResolvingUri && <Text style={searchStyle.loading}>Loading...</Text>}
{isResolvingUri && (
<View>
<Text style={searchStyle.uri}>{uri}</Text>
<View style={searchStyle.row}>
<ActivityIndicator size={"small"} color={Colors.LbryGreen} />
</View>
</View>)}
{!isResolvingUri && <Text style={searchStyle.title}>{title || name}</Text>}
{!isResolvingUri && channel && <Text style={searchStyle.publisher}>{channel}</Text>}
</View>
@@ -0,0 +1,10 @@
import { connect } from 'react-redux';
import SearchRightHeaderIcon from './view';
import { ACTIONS } from 'lbry-redux';
const perform = dispatch => ({
clearQuery: () => dispatch({
type: ACTIONS.HISTORY_NAVIGATE
})
});
export default connect(null, perform)(SearchRightHeaderIcon);
@@ -0,0 +1,20 @@
import React from 'react';
import { NavigationActions } from 'react-navigation';
import Feather from "react-native-vector-icons/Feather";
class SearchRightHeaderIcon extends React.PureComponent {
clearAndGoBack() {
const { navigation } = this.props;
this.props.clearQuery();
navigation.dispatch(NavigationActions.back())
}
render() {
const { style } = this.props;
return <Feather name="x" size={24} style={style} onPress={() => this.clearAndGoBack()} />;
}
}
export default SearchRightHeaderIcon;
@@ -23,7 +23,11 @@ class TransactionListItem extends React.PureComponent {
{name && claimId && (
<Link
style={transactionListStyle.link}
onPress={() => navigation && navigation.navigate('File', { uri: buildURI({ claimName: name, claimId }) })}
onPress={() => navigation && navigation.navigate({
routeName: 'File',
key: evt.Url,
params: { uri: buildURI({ claimName: name, claimId }) }})
}
text={name} />
)}
</View>
+17
View File
@@ -0,0 +1,17 @@
import { connect } from 'react-redux';
import { doUpdateSearchQuery, selectSearchState as selectSearch } from 'lbry-redux';
import UriBar from './view';
const select = state => {
const { ...searchState } = selectSearch(state);
return {
...searchState
};
};
const perform = dispatch => ({
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
});
export default connect(select, perform)(UriBar);
@@ -0,0 +1,38 @@
// @flow
import React from 'react';
import { SEARCH_TYPES, normalizeURI } from 'lbry-redux';
import { Text, TouchableOpacity, View } from 'react-native';
import Feather from 'react-native-vector-icons/Feather';
import uriBarStyle from '../../../styles/uriBar';
class UriBarItem extends React.PureComponent {
render() {
const { item, onPress } = this.props;
const { shorthand, type, value } = item;
let icon;
switch (type) {
case SEARCH_TYPES.CHANNEL:
icon = <Feather name="at-sign" size={18} />
break;
case SEARCH_TYPES.SEARCH:
icon = <Feather name="search" size={18} />
break;
case SEARCH_TYPES.FILE:
default:
icon = <Feather name="file" size={18} />
break;
}
return (
<TouchableOpacity style={uriBarStyle.item} onPress={onPress}>
{icon}
<Text style={uriBarStyle.itemText} numberOfLines={1}>{shorthand || value} - {type === 'search' ? 'Search' : value}</Text>
</TouchableOpacity>
)
}
}
export default UriBarItem;
+123
View File
@@ -0,0 +1,123 @@
// @flow
import React from 'react';
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
import { FlatList, Keyboard, TextInput, View } from 'react-native';
import UriBarItem from './internal/uri-bar-item';
import uriBarStyle from '../../styles/uriBar';
class UriBar extends React.PureComponent {
static INPUT_TIMEOUT = 500;
textInput = null;
keyboardDidHideListener = null;
componentDidMount () {
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
}
componentWillUnmount() {
if (this.keyboardDidHideListener) {
this.keyboardDidHideListener.remove();
}
}
constructor(props) {
super(props);
this.state = {
changeTextTimeout: null,
currentValue: null,
inputText: null,
focused: false
};
}
handleChangeText = text => {
const newValue = text ? text : '';
clearTimeout(this.state.changeTextTimeout);
const { updateSearchQuery } = this.props;
let timeout = setTimeout(() => {
updateSearchQuery(text);
}, UriBar.INPUT_TIMEOUT);
this.setState({ inputText: newValue, currentValue: newValue, changeTextTimeout: timeout });
}
handleItemPress = (item) => {
const { navigation, updateSearchQuery } = this.props;
const { type, value } = item;
Keyboard.dismiss();
if (SEARCH_TYPES.SEARCH === type) {
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: value }});
} else {
const uri = normalizeURI(value);
navigation.navigate({ routeName: 'File', key: uri, params: { uri }});
}
}
_keyboardDidHide = () => {
if (this.textInput) {
this.textInput.blur();
}
this.setState({ focused: false });
}
render() {
const { navigation, suggestions, updateSearchQuery, value } = this.props;
if (this.state.currentValue === null) {
this.setState({ currentValue: value });
}
let style = [uriBarStyle.overlay];
if (this.state.focused) {
style.push(uriBarStyle.inFocus);
}
return (
<View style={style}>
{this.state.focused && (
<View style={uriBarStyle.suggestions}>
<FlatList style={uriBarStyle.suggestionList}
data={suggestions}
keyboardShouldPersistTaps={'handled'}
keyExtractor={(item, value) => item.value}
renderItem={({item}) => <UriBarItem item={item}
navigation={navigation}
onPress={() => this.handleItemPress(item)} />} />
</View>)}
<View style={uriBarStyle.uriContainer}>
<TextInput ref={(ref) => { this.textInput = ref }}
style={uriBarStyle.uriText}
selectTextOnFocus={true}
placeholder={'Search for videos, music, games and more'}
underlineColorAndroid={'transparent'}
numberOfLines={1}
clearButtonMode={'while-editing'}
value={this.state.currentValue}
returnKeyType={'go'}
inlineImageLeft={'baseline_search_black_24'}
inlineImagePadding={16}
onFocus={() => this.setState({ focused: true })}
onBlur={() => this.setState({ focused: false })}
onChangeText={this.handleChangeText}
onSubmitEditing={() => {
if (this.state.inputText) {
let inputText = this.state.inputText;
if (isNameValid(inputText) || isURIValid(inputText)) {
const uri = normalizeURI(inputText);
navigation.navigate({ routeName: 'File', key: uri, params: { uri }});
} else {
// Open the search page with the query populated
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: inputText }});
}
}
}}/>
</View>
</View>
);
}
}
export default UriBar;
+41 -11
View File
@@ -16,9 +16,13 @@ type Props = {
};
class WalletSend extends React.PureComponent<Props> {
amountInput = null;
state = {
amount: null,
address: null
address: null,
addressChanged: false,
addressValid: false
};
componentWillUpdate(nextProps) {
@@ -52,6 +56,22 @@ class WalletSend extends React.PureComponent<Props> {
this.setState({ address: null, amount: null });
}
}
handleAddressInputBlur = () => {
if (this.state.addressChanged && !this.state.addressValid) {
const { notify } = this.props;
notify({
message: 'The recipient address is not a valid LBRY address.',
displayType: ['toast']
});
}
}
handleAddressInputSubmit = () => {
if (this.amountInput) {
this.amountInput.focus();
}
}
render() {
const { balance } = this.props;
@@ -62,20 +82,30 @@ class WalletSend extends React.PureComponent<Props> {
return (
<View style={walletStyle.card}>
<Text style={walletStyle.title}>Send Credits</Text>
<Text style={walletStyle.text}>Amount</Text>
<View style={[walletStyle.amountRow, walletStyle.bottomMarginMedium]}>
<TextInput onChangeText={value => this.setState({amount: value})}
keyboardType={'numeric'}
value={this.state.amount}
style={[walletStyle.input, walletStyle.amountInput]} />
<Text style={[walletStyle.text, walletStyle.currency]}>LBC</Text>
</View>
<Text style={walletStyle.text}>Recipient address</Text>
<View style={walletStyle.row}>
<TextInput onChangeText={value => this.setState({address: value})}
<View style={[walletStyle.row, walletStyle.bottomMarginMedium]}>
<TextInput onChangeText={value => this.setState({
address: value,
addressChanged: true,
addressValid: (value.trim().length == 0 || regexAddress.test(value))
})}
onBlur={this.handleAddressInputBlur}
onSubmitEditing={this.handleAddressInputSubmit}
placeholder={'bbFxRyXXXXXXXXXXXZD8nE7XTLUxYnddTs'}
value={this.state.address}
returnKeyType={'next'}
style={[walletStyle.input, walletStyle.addressInput, walletStyle.bottomMarginMedium]} />
</View>
<Text style={walletStyle.text}>Amount</Text>
<View style={walletStyle.row}>
<View style={walletStyle.amountRow}>
<TextInput ref={ref => this.amountInput = ref}
onChangeText={value => this.setState({amount: value})}
keyboardType={'numeric'}
value={this.state.amount}
style={[walletStyle.input, walletStyle.amountInput]} />
<Text style={[walletStyle.text, walletStyle.currency]}>LBC</Text>
</View>
<Button text={'Send'}
style={[walletStyle.button, walletStyle.sendButton]}
disabled={!canSend}
+3 -13
View File
@@ -61,7 +61,7 @@ function enableBatching(reducer) {
}
const router = AppNavigator.router;
const navAction = router.getActionForPathAndParams('Splash');
const navAction = router.getActionForPathAndParams('FirstRun');
const initialNavState = router.getStateForAction(navAction);
const navigatorReducer = (state = initialNavState, action) => {
const nextState = AppNavigator.router.getStateForAction(action, state);
@@ -116,21 +116,11 @@ 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}>
<AppWithNavigationState />
</Provider>
<AppWithNavigationState />
</Provider>
);
}
}
+12
View File
@@ -1,6 +1,7 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { NativeModules, Text, View, ScrollView } from 'react-native';
import Link from '../../component/link';
import PageHeader from '../../component/pageHeader';
import aboutStyle from '../../styles/about';
@@ -38,6 +39,17 @@ class AboutPage extends React.PureComponent {
<PageHeader title={"About LBRY"}
onBackPressed={() => { this.props.navigation.goBack(); }} />
<ScrollView style={aboutStyle.scrollContainer}>
<Text style={aboutStyle.title}>Content Freedom</Text>
<Text style={aboutStyle.paragraph}>
LBRY is a free, open, and community-run digital marketplace. It is a decentralized peer-to-peer
content distribution platform for creators to upload and share content, and earn LBRY credits
for their effort. Users will be able to find a wide selection of videos, music, ebooks and other
digital content they are interested in.
</Text>
<View style={aboutStyle.links}>
<Link style={aboutStyle.link} href="https://lbry.io/faq/what-is-lbry" text="What is LBRY?" />
<Link style={aboutStyle.link} href="https://lbry.io/faq" text="Frequently Asked Questions" />
</View>
<Text style={aboutStyle.releaseInfoTitle}>Release information</Text>
<View style={aboutStyle.row}>
<View style={aboutStyle.col}><Text style={aboutStyle.text}>App version</Text></View>
+22
View File
@@ -0,0 +1,22 @@
import { connect } from 'react-redux';
import {
doFetchClaimsByChannel,
doFetchClaimCountByChannel,
makeSelectClaimForUri,
makeSelectClaimsInChannelForPage,
makeSelectFetchingChannelClaims,
} from 'lbry-redux';
import ChannelPage from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
claimsInChannel: makeSelectClaimsInChannelForPage(props.uri, props.page || 1)(state),
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
});
const perform = dispatch => ({
fetchClaims: (uri, page) => dispatch(doFetchClaimsByChannel(uri, page)),
fetchClaimCount: uri => dispatch(doFetchClaimCountByChannel(uri)),
});
export default connect(select, perform)(ChannelPage);
+58
View File
@@ -0,0 +1,58 @@
// @flow
import React from 'react';
import { ActivityIndicator, Text, View } from 'react-native';
import Colors from '../../styles/colors';
import FileList from '../../component/fileList';
import PageHeader from '../../component/pageHeader';
import UriBar from '../../component/uriBar';
import channelPageStyle from '../../styles/channelPage';
class ChannelPage extends React.PureComponent {
componentDidMount() {
const { uri, page, claimsInChannel, fetchClaims, fetchClaimCount } = this.props;
if (!claimsInChannel || !claimsInChannel.length) {
fetchClaims(uri, page || 1);
fetchClaimCount(uri);
}
}
render() {
const { fetching, claimsInChannel, claim, navigation, uri } = this.props;
const { name, permanent_url: permanentUrl } = claim;
let contentList;
if (fetching) {
contentList = (
<View style={channelPageStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.LbryGreen} />
<Text style={channelPageStyle.infoText}>Fetching content...</Text>
</View>
);
} else {
contentList =
claimsInChannel && claimsInChannel.length ? (
<FileList sortByHeight
hideFilter
fileInfos={claimsInChannel}
navigation={navigation}
style={channelPageStyle.fileList} />
) : (
<View style={channelPageStyle.busyContainer}>
<Text style={channelPageStyle.infoText}>No content found.</Text>
</View>
);
}
return (
<View style={channelPageStyle.container}>
<PageHeader title={name} onBackPressed={() => { this.props.navigation.goBack(); }} />
{contentList}
<UriBar value={uri} navigation={navigation} />
</View>
)
}
}
export default ChannelPage;
+35 -20
View File
@@ -1,9 +1,19 @@
import React from 'react';
import FeaturedCategory from '../../component/featuredCategory';
import NavigationActions from 'react-navigation';
import { AsyncStorage, NativeModules, ScrollView, Text, View } from 'react-native';
import {
ActivityIndicator,
AsyncStorage,
NativeModules,
SectionList,
Text,
View
} from 'react-native';
import { normalizeURI } from 'lbry-redux';
import moment from 'moment';
import FileItem from '../../component/fileItem';
import discoverStyle from '../../styles/discover';
import Colors from '../../styles/colors';
import UriBar from '../../component/uriBar';
import Feather from 'react-native-vector-icons/Feather';
class DiscoverPage extends React.PureComponent {
@@ -34,31 +44,36 @@ class DiscoverPage extends React.PureComponent {
}
render() {
const { featuredUris, fetchingFeaturedUris } = this.props;
const { featuredUris, fetchingFeaturedUris, navigation } = this.props;
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length,
failedToLoad = !fetchingFeaturedUris && !hasContent;
return (
<View style={discoverStyle.container}>
{!hasContent && fetchingFeaturedUris && <Text style={discoverStyle.title}>Fetching content...</Text>}
{!hasContent && fetchingFeaturedUris && (
<View style={discoverStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.LbryGreen} />
<Text style={discoverStyle.title}>Fetching content...</Text>
</View>
)}
{hasContent &&
<ScrollView style={discoverStyle.scrollContainer}>
{hasContent &&
Object.keys(featuredUris).map(
category =>
featuredUris[category].length ? (
<FeaturedCategory
key={category}
category={category}
names={featuredUris[category]}
navigation={this.props.navigation}
/>
) : (
''
)
)}
</ScrollView>
<SectionList style={discoverStyle.scrollContainer}
renderItem={ ({item, index, section}) => (
<FileItem
style={discoverStyle.fileItem}
key={item}
uri={normalizeURI(item)}
navigation={navigation} />
)
}
renderSectionHeader={
({section: {title}}) => (<Text style={discoverStyle.categoryName}>{title}</Text>)
}
sections={Object.keys(featuredUris).map(category => ({ title: category, data: featuredUris[category] }))}
keyExtractor={(item, index) => item}
/>
}
<UriBar navigation={navigation} />
</View>
);
}
+8 -2
View File
@@ -1,13 +1,16 @@
import { connect } from 'react-redux';
import {
doFetchFileInfo,
makeSelectFileInfoForUri,
doResolveUri,
doFetchCostInfoForUri,
makeSelectIsUriResolving,
makeSelectCostInfoForUri,
makeSelectFileInfoForUri,
makeSelectClaimForUri,
makeSelectContentTypeForUri,
makeSelectMetadataForUri,
selectRewardContentClaimIds,
makeSelectCostInfoForUri
selectBlackListedOutpoints,
} from 'lbry-redux';
import { doDeleteFile, doStopDownloadingFile } from '../../redux/actions/file';
import FilePage from './view';
@@ -15,7 +18,9 @@ import FilePage from './view';
const select = (state, props) => {
const selectProps = { uri: props.navigation.state.params.uri };
return {
blackListedOutpoints: selectBlackListedOutpoints(state),
claim: makeSelectClaimForUri(selectProps.uri)(state),
isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state),
contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
metadata: makeSelectMetadataForUri(selectProps.uri)(state),
@@ -29,6 +34,7 @@ const select = (state, props) => {
const perform = dispatch => ({
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
resolveUri: uri => dispatch(doResolveUri(uri)),
stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)),
deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => {
dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim));
+190 -63
View File
@@ -1,45 +1,70 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { Lbry, normalizeURI } from 'lbry-redux';
import {
ActivityIndicator,
Alert,
Button,
Text,
TextInput,
View,
NativeModules,
ScrollView,
StatusBar,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
NativeModules
View,
WebView
} from 'react-native';
import ImageViewer from 'react-native-image-zoom-viewer';
import Colors from '../../styles/colors';
import FileItemMedia from '../../component/fileItemMedia';
import ChannelPage from '../channel';
import FileDownloadButton from '../../component/fileDownloadButton';
import FileItemMedia from '../../component/fileItemMedia';
import FilePrice from '../../component/filePrice';
import Link from '../../component/link';
import MediaPlayer from '../../component/mediaPlayer';
import UriBar from '../../component/uriBar';
import Video from 'react-native-video';
import filePageStyle from '../../styles/filePage';
class FilePage extends React.PureComponent {
state = {
mediaLoaded: false,
fullscreenMode: false
};
static navigationOptions = {
title: ''
};
constructor(props) {
super(props);
this.state = {
mediaLoaded: false,
fullscreenMode: false,
showImageViewer: false,
showWebView: false,
imageUrls: null
};
}
componentDidMount() {
StatusBar.setHidden(false);
const { isResolvingUri, resolveUri, navigation } = this.props;
const { uri } = navigation.state.params;
if (!isResolvingUri) resolveUri(uri);
this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('Open File Page', { Uri: this.props.navigation.state.params.uri });
NativeModules.Mixpanel.track('Open File Page', { Uri: uri });
}
}
componentWillReceiveProps(nextProps) {
this.fetchFileInfo(nextProps);
componentDidUpdate() {
this.fetchFileInfo(this.props);
const { isResolvingUri, resolveUri, claim, navigation } = this.props;
const { uri } = navigation.state.params;
if (!isResolvingUri && claim === undefined && uri) {
resolveUri(uri);
}
}
fetchFileInfo(props) {
@@ -102,6 +127,41 @@ class FilePage extends React.PureComponent {
}
}
localUriForFileInfo = (fileInfo) => {
if (!fileInfo) {
return null;
}
return 'file:///' + fileInfo.download_path;
}
linkify = (text) => {
let linkifiedContent = [];
let lines = text.split(/\n/g);
linkifiedContent = lines.map((line, i) => {
let tokens = line.split(/\s/g);
let lineContent = tokens.length === 0 ? '' : tokens.map((token, j) => {
let hasSpace = j !== (tokens.length - 1);
let space = hasSpace ? ' ' : '';
if (token.match(/^(lbry|https?):\/\//g)) {
return (
<Link key={j}
style={filePageStyle.link}
href={token}
text={token} />
);
} else {
return token + space;
}
});
lineContent.push("\n");
return (<Text key={i}>{lineContent}</Text>);
});
return linkifiedContent;
}
render() {
const {
claim,
@@ -110,61 +170,128 @@ class FilePage extends React.PureComponent {
contentType,
tab,
rewardedContentClaimIds,
isResolvingUri,
blackListedOutpoints,
navigation
} = this.props;
} = this.props;
const { uri } = navigation.state.params;
if (!claim || !metadata) {
return (
let innerContent = null;
if ((isResolvingUri && !claim) || !claim) {
innerContent = (
<View style={filePageStyle.container}>
<Text style={filePageStyle.emptyClaimText}>Empty claim or metadata info.</Text>
{isResolvingUri &&
<View style={filePageStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.LbryGreen} />
<Text style={filePageStyle.infoText}>Loading decentralized data...</Text>
</View>}
{claim === null && !isResolvingUri &&
<View style={filePageStyle.container}>
<Text style={filePageStyle.emptyClaimText}>There's nothing at this location.</Text>
</View>
}
<UriBar value={uri} navigation={navigation} />
</View>
);
} else if (claim && claim.name.length && claim.name[0] === '@') {
innerContent = (
<ChannelPage uri={uri} navigation={navigation} />
);
} else if (claim) {
const completed = fileInfo && fileInfo.completed;
const title = metadata.title;
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
const description = metadata.description ? metadata.description : null;
const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio';
const { height, channel_name: channelName, value } = claim;
const showActions = !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView &&
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const channelClaimId =
value && value.publisherSignature && value.publisherSignature.certificateId;
const playerStyle = [filePageStyle.player, this.state.fullscreenMode ?
filePageStyle.fullscreenPlayer : filePageStyle.containedPlayer];
const playerBgStyle = [filePageStyle.playerBackground, this.state.fullscreenMode ?
filePageStyle.fullscreenPlayerBackground : filePageStyle.containedPlayerBackground];
// at least 2MB (or the full download) before media can be loaded
const canLoadMedia = fileInfo &&
(fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes == fileInfo.total_bytes); // 2MB = 1024*1024*2
const canOpen = (mediaType === 'image' || mediaType === 'text') && completed;
const isWebViewable = mediaType === 'text';
const localFileUri = this.localUriForFileInfo(fileInfo);
const openFile = () => {
if (mediaType === 'image') {
// use image viewer
this.setState({
imageUrls: [{
url: localFileUri
}],
showImageViewer: true
});
}
if (isWebViewable) {
// show webview
this.setState({
showWebView: true
});
}
}
innerContent = (
<View style={filePageStyle.pageContainer}>
{this.state.showWebView && isWebViewable && <WebView source={{ uri: localFileUri }}
style={filePageStyle.viewer} />}
{this.state.showImageViewer && <ImageViewer style={StyleSheet.flatten(filePageStyle.viewer)}
imageUrls={this.state.imageUrls}
renderIndicator={() => null} />}
{!this.state.showWebView && (
<View style={filePageStyle.innerPageContainer}>
<View style={filePageStyle.mediaContainer}>
{(canOpen || (!fileInfo || (isPlayable && !canLoadMedia))) &&
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={metadata.thumbnail} />}
{(canOpen || (isPlayable && !this.state.mediaLoaded)) && <ActivityIndicator size="large" color={Colors.LbryGreen} style={filePageStyle.loading} />}
{((isPlayable && !completed && !canLoadMedia) || !completed || canOpen) &&
<FileDownloadButton uri={uri} style={filePageStyle.downloadButton} openFile={openFile} />}
{!fileInfo && <FilePrice uri={uri} style={filePageStyle.filePriceContainer} textStyle={filePageStyle.filePriceText} />}
</View>
{canLoadMedia && <View style={playerBgStyle} />}
{canLoadMedia && <MediaPlayer fileInfo={fileInfo}
uri={uri}
style={playerStyle}
onFullscreenToggled={this.handleFullscreenToggle}
onMediaLoaded={() => { this.setState({ mediaLoaded: true }); }}/>}
{ showActions &&
<View style={filePageStyle.actions}>
{completed && <Button color="red" title="Delete" onPress={this.onDeletePressed} />}
{!completed && fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes &&
<Button color="red" title="Stop Download" onPress={this.onStopDownloadPressed} />
}
</View>}
<ScrollView style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}>
<Text style={filePageStyle.title} selectable={true}>{title}</Text>
{channelName && <Link style={filePageStyle.channelName}
selectable={true}
text={channelName}
onPress={() => {
const channelUri = normalizeURI(channelName);
navigation.navigate({ routeName: 'File', key: channelUri, params: { uri: channelUri }});
}} />}
{description && <Text style={filePageStyle.description} selectable={true}>{this.linkify(description)}</Text>}
</ScrollView>
</View>
)}
<UriBar value={uri} navigation={navigation} />
</View>
);
}
const completed = fileInfo && fileInfo.completed;
const title = metadata.title;
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
const description = metadata.description ? metadata.description : null;
const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio';
const { height, channel_name: channelName, value } = claim;
const showActions = !this.state.fullscreenMode && (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const channelClaimId =
value && value.publisherSignature && value.publisherSignature.certificateId;
return (
<View style={filePageStyle.pageContainer}>
<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={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 }); }}/>}
</View>
{ showActions &&
<View style={filePageStyle.actions}>
{completed && <Button color="red" title="Delete" onPress={this.onDeletePressed} />}
{!completed && fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes &&
<Button color="red" title="Stop Download" onPress={this.onStopDownloadPressed} />
}
</View>}
<ScrollView style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}>
<Text style={filePageStyle.title}>{title}</Text>
{channelName && <Text style={filePageStyle.channelName}>{channelName}</Text>}
{description && <Text style={filePageStyle.description}>{description}</Text>}
</ScrollView>
<View style={filePageStyle.uriContainer}>
<TextInput style={filePageStyle.uriText}
underlineColorAndroid={'transparent'}
numberOfLines={1}
value={navigation.state.params.uri} />
</View>
</View>
);
return innerContent;
}
}
+6
View File
@@ -0,0 +1,6 @@
import { connect } from 'react-redux';
import FirstRun from './view';
const perform = dispatch => ({});
export default connect(null, perform)(FirstRun);
@@ -0,0 +1,21 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { View, Text, Linking } from 'react-native';
import Colors from '../../../styles/colors';
import firstRunStyle from '../../../styles/firstRun';
class WelcomePage extends React.PureComponent {
render() {
return (
<View style={firstRunStyle.container}>
<Text style={firstRunStyle.title}>Welcome to LBRY.</Text>
<Text style={firstRunStyle.paragraph}>LBRY is a decentralized peer-to-peer content sharing platform where
you can upload and download videos, music, ebooks and other forms of digital content.</Text>
<Text style={firstRunStyle.paragraph}>We make use of a blockchain which needs to be synchronized before
you can use the app. Synchronization may take a while because this is the first app launch.</Text>
</View>
);
}
}
export default WelcomePage;
+96
View File
@@ -0,0 +1,96 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import {
Linking,
NativeModules,
Text,
TouchableOpacity,
View
} from 'react-native';
import { NavigationActions } from 'react-navigation';
import Colors from '../../styles/colors';
import WelcomePage from './internal/welcome-page';
import firstRunStyle from '../../styles/firstRun';
class FirstRunScreen extends React.PureComponent {
static pages = ['welcome'];
constructor() {
super();
this.state = {
currentPage: null,
launchUrl: null,
isFirstRun: false
}
}
componentDidMount() {
Linking.getInitialURL().then((url) => {
if (url) {
this.setState({ launchUrl: url });
}
});
if (NativeModules.FirstRun) {
NativeModules.FirstRun.isFirstRun().then(firstRun => {
this.setState({ isFirstRun: firstRun });
if (firstRun) {
this.setState({ currentPage: FirstRunScreen.pages[0] });
} else {
// Not the first run. Navigate to the splash screen right away
this.launchSplashScreen();
}
});
} else {
// The first run module was not detected. Go straight to the splash screen.
this.launchSplashScreen();
}
}
launchSplashScreen() {
const { navigation } = this.props;
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Splash', params: { launchUri: this.state.launchUri } })
]
});
navigation.dispatch(resetAction);
}
handleContinuePressed = () => {
const pageIndex = FirstRunScreen.pages.indexOf(this.state.currentPage);
if (pageIndex === (FirstRunScreen.pages.length - 1)) {
// Final page. Let the app know that first run experience is completed.
if (NativeModules.FirstRun) {
NativeModules.FirstRun.firstRunCompleted();
}
// Navigate to the splash screen
this.launchSplashScreen();
} else {
// TODO: Page transition animation?
this.state.currentPage = FirstRunScreen.pages[pageIndex + 1];
}
}
render() {
let page = null;
if (this.state.currentPage === 'welcome') {
// show welcome page
page = (<WelcomePage />);
}
return (
<View style={firstRunStyle.screenContainer}>
{page}
{this.state.currentPage &&
<TouchableOpacity style={firstRunStyle.button} onPress={this.handleContinuePressed}>
<Text style={firstRunStyle.buttonText}>Continue</Text>
</TouchableOpacity>}
</View>
)
}
}
export default FirstRunScreen;
+24 -4
View File
@@ -8,14 +8,29 @@ import {
View,
ScrollView
} from 'react-native';
import SearchResultItem from '../../component/searchResultItem';
import Colors from '../../styles/colors';
import PageHeader from '../../component/pageHeader';
import SearchResultItem from '../../component/searchResultItem';
import UriBar from '../../component/uriBar';
import searchStyle from '../../styles/search';
class SearchPage extends React.PureComponent {
static navigationOptions = {
title: 'Search Results'
};
componentDidMount() {
const { navigation, search } = this.props;
const { searchQuery } = navigation.state.params;
if (searchQuery && searchQuery.trim().length > 0) {
search(searchQuery);
}
}
render() {
const { isSearching, navigation, uris } = this.props;
const { isSearching, navigation, uris, query } = this.props;
const { searchQuery } = navigation.state.params;
return (
<View style={searchStyle.container}>
{!isSearching && (!uris || uris.length === 0) &&
@@ -26,10 +41,15 @@ class SearchPage extends React.PureComponent {
uri={uri}
style={searchStyle.resultItem}
navigation={navigation}
onPress={() => {navigation.navigate('File', { uri: uri }); }}/>)
onPress={() => navigation.navigate({
routeName: 'File',
key: 'filePage',
params: { uri }})
}/>)
) : null }
</ScrollView>
{isSearching && <ActivityIndicator size="large" color={Colors.LbryGreen} style={searchStyle.loading} /> }
<UriBar value={searchQuery} navigation={navigation} />
</View>
);
}
+5 -2
View File
@@ -16,7 +16,10 @@ class SettingsPage extends React.PureComponent {
showNsfw,
setClientSetting
} = this.props;
// If no true / false value set, default to true
const actualKeepDaemonRunning = (keepDaemonRunning === undefined || keepDaemonRunning === null) ? true : keepDaemonRunning;
return (
<View>
<PageHeader title={"Settings"}
@@ -47,7 +50,7 @@ class SettingsPage extends React.PureComponent {
<Text style={settingsStyle.description}>Enable this option for quicker app launch and to keep the synchronisation with the blockchain up to date.</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch value={keepDaemonRunning} onValueChange={(value) => setClientSetting(SETTINGS.KEEP_DAEMON_RUNNING, value)} />
<Switch value={actualKeepDaemonRunning} onValueChange={(value) => setClientSetting(SETTINGS.KEEP_DAEMON_RUNNING, value)} />
</View>
</View>
</ScrollView>
+36 -7
View File
@@ -1,21 +1,38 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { View, Text, NativeModules } from 'react-native';
import { ActivityIndicator, View, Text, Linking, NativeModules } from 'react-native';
import { NavigationActions } from 'react-navigation';
import PropTypes from 'prop-types';
import Colors from '../../styles/colors';
import splashStyle from '../../styles/splash';
class SplashScreen extends React.PureComponent {
static navigationOptions = {
title: 'Splash'
};
componentWillMount() {
this.setState({
details: 'Starting daemon',
message: 'Connecting',
isRunning: false,
isLagging: false,
launchUrl: null
});
if (NativeModules.DaemonServiceControl) {
NativeModules.DaemonServiceControl.startService();
}
}
componentDidMount() {
// Start measuring the first launch time from the splash screen (time from daemon start to user interaction)
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()));
}
});
}
@@ -24,7 +41,7 @@ class SplashScreen extends React.PureComponent {
this._updateStatusCallback(status);
});
}
_updateStatusCallback(status) {
const startupStatus = status.startup_status;
if (startupStatus.code == 'started') {
@@ -43,7 +60,7 @@ class SplashScreen extends React.PureComponent {
// Leave the splash screen
const { balanceSubscribe, navigation } = this.props;
balanceSubscribe();
const resetAction = NavigationActions.reset({
index: 0,
actions: [
@@ -51,6 +68,11 @@ class SplashScreen extends React.PureComponent {
]
});
navigation.dispatch(resetAction);
const launchUrl = navigation.state.params.launchUrl || this.state.launchUrl;
if (launchUrl) {
navigation.navigate({ routeName: 'File', key: launchUrl, params: { uri: launchUrl } });
}
});
return;
}
@@ -73,12 +95,18 @@ class SplashScreen extends React.PureComponent {
this.updateStatus();
}, 500);
}
componentDidMount() {
if (NativeModules.Mixpanel) {
NativeModules.Mixpanel.track('App Launch', null);
}
Linking.getInitialURL().then((url) => {
if (url) {
this.setState({ launchUrl: url });
}
});
Lbry
.connect()
.then(() => {
@@ -96,10 +124,11 @@ class SplashScreen extends React.PureComponent {
render() {
const { message, details, isLagging, isRunning } = this.state;
return (
<View style={splashStyle.container}>
<Text style={splashStyle.title}>LBRY</Text>
<ActivityIndicator color={Colors.White} style={splashStyle.loading} size={"small"} />
<Text style={splashStyle.message}>{message}</Text>
<Text style={splashStyle.details}>{details}</Text>
</View>
+14
View File
@@ -0,0 +1,14 @@
import { connect } from 'react-redux';
import { doFetchTrendingUris, selectTrendingUris, selectFetchingTrendingUris } from 'lbry-redux';
import TrendingPage from './view';
const select = state => ({
trendingUris: selectTrendingUris(state),
fetchingTrendingUris: selectFetchingTrendingUris(state),
});
const perform = dispatch => ({
fetchTrendingUris: () => dispatch(doFetchTrendingUris()),
});
export default connect(select, perform)(TrendingPage);
+57
View File
@@ -0,0 +1,57 @@
import React from 'react';
import NavigationActions from 'react-navigation';
import {
ActivityIndicator,
AsyncStorage,
NativeModules,
FlatList,
Text,
View
} from 'react-native';
import { normalizeURI } from 'lbry-redux';
import moment from 'moment';
import FileItem from '../../component/fileItem';
import discoverStyle from '../../styles/discover';
import Colors from '../../styles/colors';
import UriBar from '../../component/uriBar';
import Feather from 'react-native-vector-icons/Feather';
class TrendingPage extends React.PureComponent {
componentDidMount() {
this.props.fetchTrendingUris();
}
render() {
const { trendingUris, fetchingTrendingUris, navigation } = this.props;
const hasContent = typeof trendingUris === 'object' && trendingUris.length,
failedToLoad = !fetchingTrendingUris && !hasContent;
return (
<View style={discoverStyle.container}>
{!hasContent && fetchingTrendingUris && (
<View style={discoverStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.LbryGreen} />
<Text style={discoverStyle.title}>Fetching content...</Text>
</View>
)}
{hasContent &&
<FlatList style={discoverStyle.trendingContainer}
renderItem={ ({item}) => (
<FileItem
style={discoverStyle.fileItem}
key={item}
uri={normalizeURI(item)}
navigation={navigation} />
)
}
data={trendingUris.map(uri => uri.url)}
keyExtractor={(item, index) => item}
/>
}
<UriBar navigation={navigation} />
</View>
);
}
}
export default TrendingPage;
+43 -19
View File
@@ -1,12 +1,15 @@
import {
ACTIONS,
Lbry,
doNotify,
formatCredits,
selectBalance,
makeSelectCostInfoForUri,
makeSelectFileInfoForUri,
makeSelectMetadataForUri,
selectDownloadingByOutpoint,
} from 'lbry-redux';
import { NativeModules } from 'react-native';
import { Alert, NativeModules } from 'react-native';
const DOWNLOAD_POLL_INTERVAL = 250;
@@ -34,7 +37,9 @@ export function doUpdateLoadStatus(uri, outpoint) {
},
});
NativeModules.LbryDownloadManager.updateDownload(uri, fileInfo.file_name, 100, writtenBytes, totalBytes);
if (NativeModules.LbryDownloadManager) {
NativeModules.LbryDownloadManager.updateDownload(uri, fileInfo.file_name, 100, writtenBytes, totalBytes);
}
/*const notif = new window.Notification('LBRY Download Complete', {
body: fileInfo.metadata.stream.metadata.title,
@@ -58,7 +63,9 @@ export function doUpdateLoadStatus(uri, outpoint) {
},
});
NativeModules.LbryDownloadManager.updateDownload(uri, fileInfo.file_name, progress, writtenBytes, totalBytes);
if (NativeModules.LbryDownloadManager) {
NativeModules.LbryDownloadManager.updateDownload(uri, fileInfo.file_name, progress, writtenBytes, totalBytes);
}
setTimeout(() => {
dispatch(doUpdateLoadStatus(uri, outpoint));
@@ -90,7 +97,9 @@ export function doStartDownload(uri, outpoint) {
},
});
NativeModules.LbryDownloadManager.startDownload(uri, fileInfo.file_name);
if (NativeModules.LbryDownloadManager) {
NativeModules.LbryDownloadManager.startDownload(uri, fileInfo.file_name);
}
dispatch(doUpdateLoadStatus(uri, outpoint));
});
@@ -114,7 +123,9 @@ export function doStopDownloadingFile(uri, fileInfo) {
});
});
NativeModules.LbryDownloadManager.stopDownload(uri, fileInfo.file_name);
if (NativeModules.LbryDownloadManager) {
NativeModules.LbryDownloadManager.stopDownload(uri, fileInfo.file_name);
}
// Should also delete the file after the user stops downloading
dispatch(doDeleteFile(fileInfo.outpoint, uri));
@@ -161,8 +172,10 @@ export function doLoadVideo(uri) {
data: { uri },
});
console.log(`File timeout for uri ${uri}`);
//dispatch(doOpenModal(MODALS.FILE_TIMEOUT, { uri }));
dispatch(doNotify({
message: `File timeout for uri ${uri}`,
displayType: ['toast']
}));
} else {
dispatch(doDownloadFile(uri, streamInfo));
}
@@ -174,12 +187,10 @@ export function doLoadVideo(uri) {
data: { uri },
});
console.log(`Failed to download ${uri}`);
/*dispatch(
doAlertError(
`Failed to download ${uri}, please try again. If this problem persists, visit https://lbry.io/faq/support for support.`
)
);*/
dispatch(doNotify({
message: `Failed to download ${uri}, please try again. If this problem persists, visit https://lbry.io/faq/support for support.`,
displayType: ['toast']
}));
});
};
}
@@ -189,13 +200,23 @@ export function doPurchaseUri(uri, specificCostInfo) {
const state = getState();
const balance = selectBalance(state);
const fileInfo = makeSelectFileInfoForUri(uri)(state);
const metadata = makeSelectMetadataForUri(uri)(state);
const title = metadata ? metadata.title : uri;
const downloadingByOutpoint = selectDownloadingByOutpoint(state);
const alreadyDownloading = fileInfo && !!downloadingByOutpoint[fileInfo.outpoint];
function attemptPlay(cost, instantPurchaseMax = null) {
if (cost > 0 && (!instantPurchaseMax || cost > instantPurchaseMax)) {
//dispatch(doOpenModal(MODALS.AFFIRM_PURCHASE, { uri }));
console.log('Affirm purchase...');
// display alert
const formattedCost = formatCredits(cost, 2);
const unit = cost === 1 ? 'credit' : 'credits';
Alert.alert('Confirm purchase',
`This will purchase "${title}" for ${formattedCost} ${unit}`,
[
{ text: 'OK', onPress: () => dispatch(doLoadVideo(uri)) },
{ text: 'Cancel', style: 'cancel' }
],
{ cancelable: true });
} else {
dispatch(doLoadVideo(uri));
}
@@ -223,15 +244,18 @@ export function doPurchaseUri(uri, specificCostInfo) {
if (cost > balance) {
dispatch(doSetPlayingUri(null));
//dispatch(doOpenModal(MODALS.INSUFFICIENT_CREDITS));
dispatch(doNotify({
message: 'Insufficient credits',
displayType: ['toast']
}));
Promise.resolve();
return;
}
if (cost === 0/* || !makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state)*/) {
attemptPlay(cost);
/*if (cost === 0 || !makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state)) {
attemptPlay(cost);
}
/*} else {
} else {
const instantPurchaseMax = makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state);
if (instantPurchaseMax.currency === 'LBC') {
attemptPlay(cost, instantPurchaseMax.amount);
+29 -1
View File
@@ -1,4 +1,5 @@
import { StyleSheet } from 'react-native';
import Colors from './colors';
const aboutStyle = StyleSheet.create({
scrollContainer: {
@@ -13,6 +14,33 @@ const aboutStyle = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'space-between'
},
title: {
color: Colors.LbryGreen,
fontSize: 24,
fontFamily: 'Metropolis-SemiBold',
marginLeft: 12,
marginRight: 12,
marginBottom: 8
},
paragraph: {
fontFamily: 'Metropolis-Regular',
fontSize: 16,
lineHeight: 24,
marginLeft: 12,
marginRight: 12,
marginBottom: 24
},
links: {
marginLeft: 12,
marginRight: 12,
marginBottom: 12
},
link: {
color: Colors.LbryGreen,
fontFamily: 'Metropolis-Regular',
fontSize: 16,
marginBottom: 24
},
col: {
alignSelf: 'stretch'
},
@@ -21,7 +49,7 @@ const aboutStyle = StyleSheet.create({
marginLeft: 12,
marginRight: 12,
marginBottom: 12,
fontSize: 14
fontSize: 20
},
text: {
fontFamily: 'Metropolis-SemiBold',
+37
View File
@@ -0,0 +1,37 @@
import { StyleSheet } from 'react-native';
import Colors from './colors';
const channelPageStyle = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
content: {
flex: 1
},
fileList: {
paddingTop: 30,
flex: 1,
marginBottom: 60
},
title: {
color: Colors.LbryGreen,
fontFamily: 'Metropolis-SemiBold',
fontSize: 30,
margin: 16
},
busyContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row'
},
infoText: {
fontFamily: 'Metropolis-Regular',
fontSize: 20,
textAlign: 'center',
marginLeft: 10
}
});
export default channelPageStyle;
+18 -6
View File
@@ -2,17 +2,29 @@ import { StyleSheet } from 'react-native';
const discoverStyle = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
flex: 1
},
scrollContainer: {
flex: 1
flex: 1,
marginBottom: 60,
paddingTop: 12
},
trendingContainer: {
flex: 1,
marginBottom: 60,
paddingTop: 30
},
busyContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row'
},
title: {
fontFamily: 'Metropolis-Regular',
fontSize: 20,
textAlign: 'center',
margin: 10,
marginLeft: 10
},
categoryName: {
fontFamily: 'Metropolis-Regular',
@@ -30,11 +42,11 @@ const discoverStyle = StyleSheet.create({
fileItemName: {
fontFamily: 'Metropolis-Bold',
marginTop: 8,
fontSize: 16
fontSize: 18
},
channelName: {
fontFamily: 'Metropolis-SemiBold',
fontSize: 14,
fontSize: 16,
marginTop: 4,
color: '#c0c0c0'
},
+1 -1
View File
@@ -2,7 +2,7 @@ import { StyleSheet } from 'react-native';
const fileDownloadButtonStyle = StyleSheet.create({
container: {
width: 120,
width: 160,
height: 36,
borderRadius: 18,
justifyContent: 'center',
+72 -24
View File
@@ -12,10 +12,14 @@ const filePageStyle = StyleSheet.create({
pageContainer: {
flex: 1
},
innerPageContainer: {
flex: 1,
marginBottom: 60
},
mediaContainer: {
alignItems: 'center',
width: screenWidth,
height: 220,
height: 220
},
emptyClaimText: {
fontFamily: 'Metropolis-Regular',
@@ -50,12 +54,13 @@ const filePageStyle = StyleSheet.create({
color: Colors.ChannelGrey
},
description: {
color: Colors.DescriptionGrey,
fontFamily: 'Metropolis-Regular',
fontSize: 16,
lineHeight: 20,
marginLeft: 20,
marginRight: 20,
marginBottom: 40,
color: Colors.DescriptionGrey
marginBottom: 40
},
thumbnail: {
width: screenWidth,
@@ -68,20 +73,53 @@ const filePageStyle = StyleSheet.create({
top: '40%'
},
player: {
flex: 1,
width: '100%',
height: '100%',
marginBottom: 14
},
fullscreenMedia: {
position: 'absolute',
left: 0,
top: 0,
zIndex: 101
},
containedPlayer: {
width: '100%',
height: 220,
},
fullscreenPlayer: {
width: '100%',
height: '100%',
right: 0,
bottom: 0,
flex: 1,
backgroundColor: Colors.Black,
zIndex: 100
bottom: 0
},
playerBackground: {
position: 'absolute',
left: 0,
top: 0,
zIndex: 100,
backgroundColor: Colors.Black
},
containedPlayerBackground: {
width: '100%',
height: 206,
},
fullscreenPlayerBackground: {
width: '100%',
height: '100%',
right: 0,
bottom: 0
},
filePriceContainer: {
backgroundColor: '#61fcd8',
justifyContent: 'center',
position: 'absolute',
right: 16,
top: 16,
width: 56,
height: 24,
borderRadius: 4
},
filePriceText: {
fontFamily: 'Metropolis-Bold',
fontSize: 12,
textAlign: 'center',
color: '#0c604b'
},
actions: {
paddingLeft: 16,
@@ -99,19 +137,29 @@ const filePageStyle = StyleSheet.create({
position: 'absolute',
top: '40%'
},
uriContainer: {
padding: 8,
backgroundColor: Colors.VeryLightGrey,
alignSelf: 'flex-end'
busyContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row'
},
uriText: {
backgroundColor: Colors.White,
borderWidth: 1,
borderColor: Colors.LightGrey,
padding: 8,
borderRadius: 4,
infoText: {
fontFamily: 'Metropolis-Regular',
fontSize: 16
fontSize: 20,
textAlign: 'center',
marginLeft: 10
},
viewer: {
position: 'absolute',
flex: 1,
left: 0,
right: 0,
top: 0,
bottom: 60,
zIndex: 100
},
link: {
color: Colors.LbryGreen
}
});
+44
View File
@@ -0,0 +1,44 @@
import { StyleSheet } from 'react-native';
import Colors from './colors';
const firstRunStyle = StyleSheet.create({
screenContainer: {
flex: 1,
backgroundColor: Colors.LbryGreen
},
container: {
flex: 9,
justifyContent: 'center',
backgroundColor: Colors.LbryGreen
},
title: {
fontFamily: 'Metropolis-SemiBold',
fontSize: 40,
marginLeft: 32,
marginRight: 32,
marginBottom: 32,
color: Colors.White
},
paragraph: {
fontFamily: 'Metropolis-Regular',
fontSize: 18,
lineHeight: 24,
marginLeft: 32,
marginRight: 32,
marginBottom: 20,
color: Colors.White
},
button: {
flex: 1,
alignSelf: 'flex-end',
marginLeft: 32,
marginRight: 32
},
buttonText: {
fontFamily: 'Metropolis-Regular',
fontSize: 28,
color: Colors.White
}
});
export default firstRunStyle;
+30 -16
View File
@@ -1,22 +1,29 @@
import { StyleSheet, Dimensions } from 'react-native';
const screenDimension = Dimensions.get('window');
const screenWidth = screenDimension.width;
import { StyleSheet } from 'react-native';
import Colors from './colors';
const mediaPlayerStyle = StyleSheet.create({
player: {
flex: 1
flex: 1,
width: '100%',
height: '100%'
},
container: {
flex: 1,
paddingBottom: 16
},
fullscreenContainer: {
flex: 1,
justifyContent: 'center'
},
progress: {
flex: 1,
flexDirection: 'row',
overflow: 'hidden',
width: '100%',
height: 3
},
innerProgressCompleted: {
height: 4,
backgroundColor: '#40c0a9',
backgroundColor: Colors.LbryGreen,
},
innerProgressRemaining: {
height: 4,
@@ -24,10 +31,16 @@ const mediaPlayerStyle = StyleSheet.create({
},
trackingControls: {
height: 3,
width: '100%',
position: 'absolute',
bottom: 0,
bottom: 14
},
containedTrackingControls: {
left: 0,
width: '100%'
},
fullscreenTrackingControls: {
alignSelf: 'center',
width: '70%'
},
playerControls: {
position: 'absolute',
@@ -77,24 +90,25 @@ const mediaPlayerStyle = StyleSheet.create({
seekerCircle: {
borderRadius: 12,
position: 'relative',
top: 16,
left: 8,
top: 14,
left: 15,
height: 12,
width: 12,
backgroundColor: '#40c0a9'
},
seekerHandle: {
backgroundColor: 'transparent',
position: 'absolute',
height: 36,
width: 36,
bottom: -12,
marginLeft: -8
width: 48,
bottom: 0,
marginLeft: -16
},
bigSeekerCircle: {
borderRadius: 24,
position: 'relative',
top: 10,
left: 8,
top: 8,
left: 15,
height: 24,
width: 24,
backgroundColor: '#40c0a9'
+7 -1
View File
@@ -10,7 +10,8 @@ const searchStyle = StyleSheet.create({
flex: 1,
width: '100%',
height: '100%',
padding: 16
padding: 16,
marginBottom: 60
},
scrollPadding: {
paddingBottom: 16
@@ -41,6 +42,11 @@ const searchStyle = StyleSheet.create({
fontFamily: 'Metropolis-SemiBold',
fontSize: 16
},
uri: {
fontFamily: 'Metropolis-SemiBold',
fontSize: 14,
marginBottom: 8
},
publisher: {
fontFamily: 'Metropolis-SemiBold',
fontSize: 12,
+8 -4
View File
@@ -1,30 +1,34 @@
import { StyleSheet } from 'react-native';
import Colors from './colors';
const splashStyle = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#40b89a'
backgroundColor: Colors.LbryGreen
},
title: {
fontFamily: 'Metropolis-Bold',
fontSize: 64,
textAlign: 'center',
marginBottom: 48,
color: '#ffffff'
color: Colors.White
},
loading: {
marginBottom: 36
},
details: {
fontFamily: 'Metropolis-Regular',
fontSize: 14,
marginLeft: 16,
marginRight: 16,
color: '#ffffff',
color: Colors.White,
textAlign: 'center'
},
message: {
fontFamily: 'Metropolis-Bold',
fontSize: 18,
color: '#ffffff',
color: Colors.White,
marginLeft: 16,
marginRight: 16,
marginBottom: 4,
+57
View File
@@ -0,0 +1,57 @@
import { StyleSheet } from 'react-native';
import Colors from './colors';
const uriBarStyle = StyleSheet.create({
uriContainer: {
backgroundColor: Colors.White,
padding: 8,
alignSelf: 'flex-end',
height: 60,
width: '100%',
shadowColor: Colors.Black,
shadowOpacity: 0.1,
shadowRadius: StyleSheet.hairlineWidth,
shadowOffset: {
height: StyleSheet.hairlineWidth,
},
elevation: 4
},
uriText: {
backgroundColor: Colors.White,
borderWidth: 1,
borderColor: Colors.LightGrey,
padding: 8,
borderRadius: 4,
fontFamily: 'Metropolis-Regular',
fontSize: 16,
width: '100%'
},
overlay: {
position: 'absolute',
backgroundColor: 'transparent',
bottom: 0,
width: '100%',
zIndex: 200,
elevation: 16
},
inFocus: {
height: '100%'
},
suggestions: {
backgroundColor: 'white',
flex: 1
},
item: {
flexDirection: 'row',
justifyContent: 'flex-start',
padding: 12
},
itemText: {
fontFamily: 'Metropolis-Regular',
fontSize: 16,
marginLeft: 12,
marginRight: 12
}
});
export default uriBarStyle;
+6 -2
View File
@@ -112,10 +112,14 @@ const walletStyle = StyleSheet.create({
},
amountInput: {
alignSelf: 'flex-start',
width: 150
width: 100,
fontSize: 16,
letterSpacing: 1
},
addressInput: {
width: '80%'
flex: 1,
fontSize: 16,
letterSpacing: 1.5
},
warning: {
backgroundColor: Colors.Orange,
+2 -2
View File
@@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py
# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = openssl, sqlite3, hostpython2, android, pyjnius, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pycrypto==2.6.1, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, txrequests==0.9.5, seccure==0.3.1.3, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, git+https://github.com/lbryio/lbryschema.git@v0.0.15rc2#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, cryptography==2.0.3, funcsigs, mock, pbr, unqlite
requirements = openssl, sqlite3, hostpython2, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, git+https://github.com/lbryio/lbryschema.git@v0.0.15#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, cryptography==2.2.2, pyopenssl==17.4.0, treq==17.8.0, funcsigs, mock, pbr, unqlite
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
@@ -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:+, com.mixpanel.android:mixpanel-android:5+, com.google.android.gms:play-services-gcm:11.0.4+
android.gradle_dependencies = com.android.support:appcompat-v7:23.4.0, com.facebook.react:react-native:0.55.3, 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
+2 -2
View File
@@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py
# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = openssl, sqlite3, hostpython2, android, pyjnius, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pycrypto==2.6.1, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, txrequests==0.9.5, seccure==0.3.1.3, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, git+https://github.com/lbryio/lbryschema.git@v0.0.15rc2#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, cryptography==2.0.3, funcsigs, mock, pbr, unqlite
requirements = openssl, sqlite3, hostpython2, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, git+https://github.com/lbryio/lbryschema.git@v0.0.15#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, cryptography==2.2.2, pyopenssl==17.4.0, treq==17.8.0, funcsigs, mock, pbr, unqlite
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
@@ -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:+, com.mixpanel.android:mixpanel-android:5+, com.google.android.gms:play-services-gcm:11.0.4+
android.gradle_dependencies = com.android.support:appcompat-v7:23.4.0, com.facebook.react:react-native:0.55.3, 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
@@ -371,7 +371,7 @@ main.py that loads it.''')
args=args,
url_scheme=url_scheme,
private_version=str(time.time()))
# add colors.xml
render(
'colors.tmpl.xml',
@@ -380,6 +380,14 @@ main.py that loads it.''')
url_scheme=url_scheme,
)
# add themes.xml
render(
'themes.tmpl.xml',
'src/main/res/values/themes.xml',
args=args,
url_scheme=url_scheme,
)
# add activity_service_control
render(
'activity_service_control.xml',
@@ -396,12 +404,12 @@ main.py that loads it.''')
aars=aars,
android_api=android_api,
build_tools_version=build_tools_version)
render(
'settings.tmpl.gradle',
'settings.gradle'
)
# copy icon drawables
for folder in ('drawable-hdpi', 'drawable-mdpi', 'drawable-xhdpi', 'drawable-xxhdpi', 'drawable-xxxhdpi'):
shutil.copy(
@@ -1,4 +1,5 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
@@ -307,6 +308,10 @@ JNIEXPORT void JNICALL Java_org_kivy_android_PythonService_nativeStart(
setenv("PYTHONHOME", python_home, 1);
setenv("PYTHONPATH", python_path, 1);
setenv("PYTHON_SERVICE_ARGUMENT", arg, 1);
char ca_path[128];
snprintf(ca_path, 128, "%s/lib/python2.7/site-packages/certifi/cacert.pem", python_home);
setenv("SSL_CERT_FILE", ca_path, 1);
char *argv[] = {"."};
/* ANDROID_ARGUMENT points to service subdir,
Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>
@@ -52,7 +52,7 @@
<application android:label="@string/app_name"
android:icon="@drawable/icon"
android:allowBackup="true"
android:theme="@android:style/Theme.Material.Light"
android:theme="@style/LbryAppTheme"
android:hardwareAccelerated="true">
{% for m in args.meta_data %}
@@ -64,7 +64,7 @@
android:configChanges="keyboardHidden|orientation{% if args.min_sdk_version >= 13 %}|screenSize{% endif %}"
android:screenOrientation="{{ args.orientation }}"
-->
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity android:name="io.lbry.browser.MainActivity"
@@ -72,8 +72,15 @@
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:configChanges="keyboardHidden|orientation{% if args.min_sdk_version >= 13 %}|screenSize{% endif %}"
android:screenOrientation="{{ args.orientation }}"
android:launchMode="singleInstance"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="lbry" />
</intent-filter>
{% if args.launcher %}
<intent-filter>
@@ -92,9 +99,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"
@@ -6,4 +6,5 @@
<color name="red">#FF0000</color>
<color name="green">#00C000</color>
<color name="lbrygreen">#40B89A</color>
</resources>
@@ -0,0 +1,5 @@
<resources>
<style name="LbryAppTheme" parent="@android:style/Theme.Material.Light">
<item name="android:windowBackground">@color/lbrygreen</item>
</style>
</resources>
+1 -1
View File
@@ -3,7 +3,7 @@ from os.path import dirname, join
class CryptographyRecipe(CompiledComponentsPythonRecipe):
name = 'cryptography'
version = '2.0.3'
version = '2.2.2'
url = 'https://github.com/pyca/cryptography/archive/{version}.tar.gz'
depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'pyasn1', 'six', 'setuptools', 'enum34', 'ipaddress', 'cffi']
call_hostpython_via_targetpython = False
+2 -1
View File
@@ -3,9 +3,10 @@ from pythonforandroid.toolchain import PythonRecipe
class PyASN1Recipe(PythonRecipe):
version = '0.1.8'
version = '0.4.2'
url = 'https://pypi.python.org/packages/source/p/pyasn1/pyasn1-{version}.tar.gz'
depends = ['python2']
call_hostpython_via_targetpython = False
recipe = PyASN1Recipe()
+23
View File
@@ -0,0 +1,23 @@
from pythonforandroid.toolchain import (
PythonRecipe,
Recipe,
current_directory,
info,
shprint,
)
from os.path import join
import sh
class SetuptoolsRecipe(PythonRecipe):
version = '18.5'
url = 'https://pypi.python.org/packages/source/s/setuptools/setuptools-{version}.tar.gz'
depends = ['python2']
call_hostpython_via_targetpython = False
install_in_hostpython = True
recipe = SetuptoolsRecipe()
+41 -24
View File
@@ -27,23 +27,27 @@ import io.lbry.browser.reactpackages.LbryReactPackage;
import io.lbry.browser.reactmodules.DownloadManagerModule;
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
private static final int OVERLAY_PERMISSION_REQ_CODE = 101;
private static final int STORAGE_PERMISSION_REQ_CODE = 201;
private static final int STORAGE_PERMISSION_REQ_CODE = 201;
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
public static final String SHARED_PREFERENCES_NAME = "LBRY";
/**
* Flag which indicates whether or not the service is running. Will be updated in the
* onResume method.
*/
private boolean serviceRunning;
protected String getMainComponentName() {
return "LBRYApp";
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -52,22 +56,22 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Toast.makeText(this,
"LBRY requires access to your device storage to be able to download files and media.", Toast.LENGTH_SHORT).show();
"LBRY requires access to your device storage to be able to download files and media.", Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(this,
new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, STORAGE_PERMISSION_REQ_CODE);
}
}
}
super.onCreate(savedInstanceState);
// Start the daemon service if it is not started
serviceRunning = isServiceRunning(LbrynetService.class);
if (!serviceRunning) {
ServiceHelper.start(this, "", LbrynetService.class, "lbrynetservice");
}
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
@@ -83,7 +87,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
setContentView(mReactRootView);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
@@ -94,13 +98,13 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case STORAGE_PERMISSION_REQ_CODE:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
if (!Settings.canDrawOverlays(this)) {
if (BuildConfig.DEBUG && !Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
@@ -123,30 +127,35 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
public void invokeDefaultOnBackPressed() {
super.onBackPressed();
}
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostPause(this);
}
}
@Override
protected void onResume() {
super.onResume();
serviceRunning = isServiceRunning(LbrynetService.class);
if (!serviceRunning) {
ServiceHelper.start(this, "", LbrynetService.class, "lbrynetservice");
SharedPreferences sp = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
if (!sp.getBoolean("firstRun", true)) {
// We're not showing the welcome page, so it's okay to start the daemon service
// because this is not the first run experience
serviceRunning = isServiceRunning(LbrynetService.class);
if (!serviceRunning) {
ServiceHelper.start(this, "", LbrynetService.class, "lbrynetservice");
}
}
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostResume(this, this);
}
}
@Override
protected void onDestroy() {
// check service running setting and end it here
@@ -160,7 +169,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
}
super.onDestroy();
if (mReactInstanceManager != null) {
mReactInstanceManager.onHostDestroy(this);
}
@@ -174,7 +183,15 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
super.onBackPressed();
}
}
@Override
public void onNewIntent(Intent intent) {
if (mReactInstanceManager != null) {
mReactInstanceManager.onNewIntent(intent);
}
super.onNewIntent(intent);
}
private boolean isServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningServiceInfo serviceInfo : manager.getRunningServices(Integer.MAX_VALUE)) {
@@ -24,6 +24,11 @@ public class DaemonServiceControlModule extends ReactContextBaseJavaModule {
return "DaemonServiceControl";
}
@ReactMethod
public void startService() {
ServiceHelper.start(context, "", LbrynetService.class, "lbrynetservice");
}
@ReactMethod
public void stopService() {
ServiceHelper.stop(context, LbrynetService.class);
@@ -4,6 +4,7 @@ import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
@@ -27,7 +28,7 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
private HashMap<String, Integer> downloadIdNotificationIdMap = new HashMap<String, Integer>();
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#");
private static final int MAX_PROGRESS = 100;
@@ -74,8 +75,8 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
}
}
private PendingIntent getLaunchPendingIntent() {
Intent launchIntent = new Intent(context, MainActivity.class);
private PendingIntent getLaunchPendingIntent(String uri) {
Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
launchIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, launchIntent, 0);
return intent;
@@ -87,7 +88,8 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentIntent(getLaunchPendingIntent())
// The file URI is used as the unique ID
builder.setContentIntent(getLaunchPendingIntent(id))
.setContentTitle(String.format("Downloading %s...", fileName))
.setGroup(GROUP_DOWNLOADS)
.setPriority(NotificationCompat.PRIORITY_LOW)
@@ -115,14 +117,18 @@ public class DownloadManagerModule extends ReactContextBaseJavaModule {
createNotificationGroup();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationCompat.Builder builder = builders.get(notificationId);
builder.setContentIntent(getLaunchPendingIntent())
builder.setContentIntent(getLaunchPendingIntent(id))
.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.setContentTitle(String.format("Downloaded %s", fileName))
.setContentText(String.format("%s", formatBytes(totalBytes)))
.setProgress(0, 0, false);
notificationManager.notify(notificationId, builder.build());
downloadIdNotificationIdMap.remove(id);
builders.remove(notificationId);
}
@@ -0,0 +1,44 @@
package io.lbry.browser.reactmodules;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.SharedPreferences;
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 io.lbry.browser.MainActivity;
public class FirstRunModule extends ReactContextBaseJavaModule {
private Context context;
private SharedPreferences sp;
public FirstRunModule(ReactApplicationContext reactContext) {
super(reactContext);
this.context = reactContext;
this.sp = reactContext.getSharedPreferences(MainActivity.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
}
@Override
public String getName() {
return "FirstRun";
}
@ReactMethod
public void isFirstRun(final Promise promise) {
// If firstRun flag does not exist, default to true
boolean firstRun = sp.getBoolean("firstRun", true);
promise.resolve(firstRun);
}
@ReactMethod
public void firstRunCompleted() {
SharedPreferences.Editor editor = sp.edit();
editor.putBoolean("firstRun", false);
editor.commit();
}
}
@@ -9,6 +9,8 @@ import com.facebook.react.bridge.ReadableMap;
import com.mixpanel.android.mpmetrics.MixpanelAPI;
import io.lbry.browser.BuildConfig;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONObject;
@@ -16,9 +18,9 @@ import org.json.JSONException;
public class MixpanelModule extends ReactContextBaseJavaModule {
// TODO: Detect dev / debug and release mode and update value accordingly
private static final String MIXPANEL_TOKEN = "93b81fb957cb0ddcd3198c10853a6a95"; // Production
//private static final String MIXPANEL_TOKEN = "bc1630b8be64c5dfaa4700b3a62969f3"; // Dev Testing
private static final String MIXPANEL_TOKEN = BuildConfig.DEBUG ?
"bc1630b8be64c5dfaa4700b3a62969f3" /* Dev Testing */ :
"93b81fb957cb0ddcd3198c10853a6a95"; /* Production */
private Context context;
@@ -1,15 +1,14 @@
package io.lbry.browser.reactmodules;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
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;
@@ -7,6 +7,7 @@ import com.facebook.react.uimanager.ViewManager;
import io.lbry.browser.reactmodules.DaemonServiceControlModule;
import io.lbry.browser.reactmodules.DownloadManagerModule;
import io.lbry.browser.reactmodules.FirstRunModule;
import io.lbry.browser.reactmodules.MixpanelModule;
import io.lbry.browser.reactmodules.ScreenOrientationModule;
import io.lbry.browser.reactmodules.VersionInfoModule;
@@ -27,10 +28,11 @@ public class LbryReactPackage implements ReactPackage {
modules.add(new DaemonServiceControlModule(reactContext));
modules.add(new DownloadManagerModule(reactContext));
modules.add(new FirstRunModule(reactContext));
modules.add(new MixpanelModule(reactContext));
modules.add(new ScreenOrientationModule(reactContext));
modules.add(new VersionInfoModule(reactContext));
return modules;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
__version__ = "0.1.4"
__version__ = "0.1.8"
class ServiceApp(App):
def build(self):