Publishing #577
3 changed files with 57 additions and 60 deletions
|
@ -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,7 +539,6 @@ 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>
|
||||
|
@ -581,7 +566,6 @@ class PublishPage extends React.PureComponent {
|
|||
</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}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue
This file seems fine but I'm less qualified to review Java