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; camera = null;
state = { state = {
canUseCamera: false,
// gallery videos // gallery videos
videos: null, videos: null,
@ -169,14 +171,9 @@ class PublishPage extends React.PureComponent {
pushDrawerStack(); pushDrawerStack();
setPlayerVisible(); setPlayerVisible();
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => { NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
if (thumbnailPath != null) { NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
this.setState({ thumbnailPath }); NativeModules.Gallery.getVideos().then(videos => this.setState({ videos }));
}
});
NativeModules.Gallery.getVideos().then(videos => {
this.setState({ videos });
});
}; };
componentDidMount() { componentDidMount() {
@ -254,13 +251,13 @@ class PublishPage extends React.PureComponent {
handleRecordVideoPressed = () => { handleRecordVideoPressed = () => {
if (!this.state.showCameraOverlay) { if (!this.state.showCameraOverlay) {
this.setState({ showCameraOverlay: true, videoRecordingMode: true }); this.setState({ canUseCamera: true, showCameraOverlay: true, videoRecordingMode: true });
} }
}; };
handleTakePhotoPressed = () => { handleTakePhotoPressed = () => {
if (!this.state.showCameraOverlay) { 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 = ( content = (
<View style={publishStyle.gallerySelector}> <View style={publishStyle.gallerySelector}>
<View style={publishStyle.actionsView}> <View style={publishStyle.actionsView}>
{this.state.canUseCamera &&
<RNCamera <RNCamera
style={publishStyle.cameraPreview} style={publishStyle.cameraPreview}
type={RNCamera.Constants.Type.back} 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',
}}
/>
<View style={publishStyle.actionsSubView}> <View style={publishStyle.actionsSubView}>
<TouchableOpacity style={publishStyle.record} onPress={this.handleRecordVideoPressed}> <TouchableOpacity style={publishStyle.record} onPress={this.handleRecordVideoPressed}>
<Icon name="video" size={48} color={Colors.White} /> <Icon name="video" size={48} color={Colors.White} />
@ -553,7 +539,6 @@ class PublishPage extends React.PureComponent {
<ChannelSelector onChannelChange={this.handleChannelChange} /> <ChannelSelector onChannelChange={this.handleChannelChange} />
</View> </View>
{this.state.advancedMode && (
<View style={publishStyle.card}> <View style={publishStyle.card}>
<View style={publishStyle.titleRow}> <View style={publishStyle.titleRow}>
<Text style={publishStyle.cardTitle}>Price</Text> <Text style={publishStyle.cardTitle}>Price</Text>
@ -581,7 +566,6 @@ class PublishPage extends React.PureComponent {
</View> </View>
)} )}
</View> </View>
)}
{this.state.advancedMode && ( {this.state.advancedMode && (
<View style={publishStyle.card}> <View style={publishStyle.card}>
@ -616,6 +600,13 @@ class PublishPage extends React.PureComponent {
</View> </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}> <View style={publishStyle.actionButtons}>
{(this.state.publishStarted || publishFormValues.publishing) && ( {(this.state.publishStarted || publishFormValues.publishing) && (
<View style={publishStyle.progress}> <View style={publishStyle.progress}>
@ -633,11 +624,6 @@ class PublishPage extends React.PureComponent {
{!publishFormValues.publishing && !this.state.publishStarted && ( {!publishFormValues.publishing && !this.state.publishStarted && (
<View style={publishStyle.rightActionButtons}> <View style={publishStyle.rightActionButtons}>
<Button
style={publishStyle.modeButton}
text={this.state.advancedMode ? 'Simple' : 'Advanced'}
onPress={this.handleModePressed}
/>
<Button <Button
style={publishStyle.publishButton} style={publishStyle.publishButton}
disabled={!this.state.uploadedThumbnailUri} disabled={!this.state.uploadedThumbnailUri}
@ -685,7 +671,7 @@ class PublishPage extends React.PureComponent {
{false && Constants.PHASE_SELECTOR !== this.state.currentPhase && ( {false && Constants.PHASE_SELECTOR !== this.state.currentPhase && (
<FloatingWalletBalance navigation={navigation} /> <FloatingWalletBalance navigation={navigation} />
)} )}
{this.state.showCameraOverlay && ( {this.state.canUseCamera && this.state.showCameraOverlay && (
<View style={publishStyle.cameraOverlay}> <View style={publishStyle.cameraOverlay}>
<RNCamera <RNCamera
style={publishStyle.fullCamera} style={publishStyle.fullCamera}

View file

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

View file

@ -5,6 +5,7 @@ import android.content.ContentResolver;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.Manifest;
import android.media.ThumbnailUtils; import android.media.ThumbnailUtils;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; 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.WritableArray;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import io.lbry.browser.MainActivity;
import io.lbry.browser.Utils; import io.lbry.browser.Utils;
import java.io.File; import java.io.File;
@ -310,4 +312,9 @@ public class GalleryModule extends ReactContextBaseJavaModule {
return map; 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