Publishing #577

Merged
akinwale merged 15 commits from publishing into master 2019-07-09 02:43:31 +02:00
3 changed files with 57 additions and 60 deletions
Showing only changes of commit 44c58eb8c7 - Show all commits

View file

@ -35,6 +35,8 @@ class PublishPage extends React.PureComponent {
camera = null;
state = {
canUseCamera: false,
// gallery videos
videos: null,
@ -169,14 +171,9 @@ class PublishPage extends React.PureComponent {
pushDrawerStack();
setPlayerVisible();
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => {
if (thumbnailPath != null) {
this.setState({ thumbnailPath });
}
});
NativeModules.Gallery.getVideos().then(videos => {
this.setState({ videos });
});
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos }));
};
componentDidMount() {
@ -254,13 +251,13 @@ class PublishPage extends React.PureComponent {
handleRecordVideoPressed = () => {
if (!this.state.showCameraOverlay) {
this.setState({ showCameraOverlay: true, videoRecordingMode: true });
this.setState({ canUseCamera: true, showCameraOverlay: true, videoRecordingMode: true });
}
};
handleTakePhotoPressed = () => {
if (!this.state.showCameraOverlay) {
this.setState({ showCameraOverlay: true, videoRecordingMode: false });
this.setState({ canUseCamera: true, showCameraOverlay: true, videoRecordingMode: false });
}
};
@ -446,22 +443,11 @@ class PublishPage extends React.PureComponent {
content = (
<View style={publishStyle.gallerySelector}>
<View style={publishStyle.actionsView}>
{this.state.canUseCamera &&
<RNCamera
style={publishStyle.cameraPreview}
type={RNCamera.Constants.Type.back}
androidCameraPermissionOptions={{
title: 'Camera',
message: 'Please grant access to make use of your camera',
buttonPositive: 'OK',
buttonNegative: 'Cancel',
}}
androidRecordAudioPermissionOptions={{
title: 'Audio',
message: 'Please grant access to record audio',
buttonPositive: 'OK',
buttonNegative: 'Cancel',
}}
/>
type={RNCamera.Constants.Type.back} />
}
<View style={publishStyle.actionsSubView}>
<TouchableOpacity style={publishStyle.record} onPress={this.handleRecordVideoPressed}>
<Icon name="video" size={48} color={Colors.White} />
@ -553,35 +539,33 @@ class PublishPage extends React.PureComponent {
<ChannelSelector onChannelChange={this.handleChannelChange} />
</View>
{this.state.advancedMode && (
<View style={publishStyle.card}>
<View style={publishStyle.titleRow}>
<Text style={publishStyle.cardTitle}>Price</Text>
<View style={publishStyle.switchTitleRow}>
<Switch value={this.state.priceSet} onValueChange={value => this.setState({ priceSet: value })} />
</View>
<View style={publishStyle.card}>
<View style={publishStyle.titleRow}>
<Text style={publishStyle.cardTitle}>Price</Text>
<View style={publishStyle.switchTitleRow}>
<Switch value={this.state.priceSet} onValueChange={value => this.setState({ priceSet: value })} />
</View>
{!this.state.priceSet && (
<Text style={publishStyle.cardText}>Your content will be free. Press the toggle to set a price.</Text>
)}
{this.state.priceSet && (
<View style={[publishStyle.inputRow, publishStyle.priceInputRow]}>
<TextInput
placeholder={'0.00'}
keyboardType={'number-pad'}
style={publishStyle.priceInput}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
value={String(this.state.price)}
onChangeText={this.handlePriceChange}
/>
<Text style={publishStyle.currency}>LBC</Text>
</View>
)}
</View>
)}
{!this.state.priceSet && (
<Text style={publishStyle.cardText}>Your content will be free. Press the toggle to set a price.</Text>
)}
{this.state.priceSet && (
<View style={[publishStyle.inputRow, publishStyle.priceInputRow]}>
<TextInput
placeholder={'0.00'}
keyboardType={'number-pad'}
style={publishStyle.priceInput}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
value={String(this.state.price)}
onChangeText={this.handlePriceChange}
/>
<Text style={publishStyle.currency}>LBC</Text>
</View>
)}
</View>
{this.state.advancedMode && (
<View style={publishStyle.card}>
@ -616,6 +600,13 @@ class PublishPage extends React.PureComponent {
</View>
)}
<View style={publishStyle.toggleContainer}>
<Link
text={this.state.advancedMode ? 'Hide extra fields' : 'Show extra fields'}
onPress={this.handleModePressed}
style={publishStyle.modeLink} />
</View>
<View style={publishStyle.actionButtons}>
{(this.state.publishStarted || publishFormValues.publishing) && (
<View style={publishStyle.progress}>
@ -633,11 +624,6 @@ class PublishPage extends React.PureComponent {
{!publishFormValues.publishing && !this.state.publishStarted && (
<View style={publishStyle.rightActionButtons}>
<Button
style={publishStyle.modeButton}
text={this.state.advancedMode ? 'Simple' : 'Advanced'}
onPress={this.handleModePressed}
/>
<Button
style={publishStyle.publishButton}
disabled={!this.state.uploadedThumbnailUri}
@ -685,7 +671,7 @@ class PublishPage extends React.PureComponent {
{false && Constants.PHASE_SELECTOR !== this.state.currentPhase && (
<FloatingWalletBalance navigation={navigation} />
)}
{this.state.showCameraOverlay && (
{this.state.canUseCamera && this.state.showCameraOverlay && (
<View style={publishStyle.cameraOverlay}>
<RNCamera
style={publishStyle.fullCamera}

View file

@ -44,10 +44,9 @@ const publishStyle = StyleSheet.create({
flexDirection: 'row',
alignItems: 'center',
},
modeButton: {
modeLink: {
backgroundColor: Colors.NextLbryGreen,
alignSelf: 'flex-end',
marginRight: 20,
alignSelf: 'flex-end'
},
publishButton: {
backgroundColor: Colors.LbryGreen,
@ -261,6 +260,11 @@ const publishStyle = StyleSheet.create({
alignItems: 'center',
padding: 16,
},
toggleContainer: {
marginTop: 24,
alignItems: 'center',
justifyContent: 'flex-end'
}
});
export default publishStyle;

View file

@ -5,6 +5,7 @@ import android.content.ContentResolver;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.Manifest;
import android.media.ThumbnailUtils;
import android.os.AsyncTask;
import android.os.Bundle;
@ -18,6 +19,7 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import io.lbry.browser.MainActivity;
import io.lbry.browser.Utils;
import java.io.File;
@ -310,4 +312,9 @@ public class GalleryModule extends ReactContextBaseJavaModule {
return map;
}
}
@ReactMethod
public void canUseCamera(final Promise promise) {
promise.resolve(MainActivity.hasPermission(Manifest.permission.CAMERA, MainActivity.getActivity()));
}
}
kauffj commented 2019-07-02 16:36:31 +02:00 (Migrated from github.com)
Review

This file seems fine but I'm less qualified to review Java

This file seems fine but I'm less qualified to review Java