Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] Audio Block: Add from URL #27817

Merged
merged 50 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0519567
Basics of Audio block working
etoledom Dec 1, 2020
690224d
Add audio support to MediaUpload
etoledom Dec 1, 2020
b7965fd
Add handling of file uploads and replace
etoledom Dec 1, 2020
f2ccb18
WPMediaLibrary support for Audio block
etoledom Dec 1, 2020
2a02b83
Avoid removing media info on error state
etoledom Dec 1, 2020
276b07d
Linting
etoledom Dec 1, 2020
8a8b550
Added an AUDIO file to the test requestMediaPickFromMediaLibrary func
jd-alexander Dec 9, 2020
9e03e63
Fixed typo in ToolbarButton of Audio Block.
jd-alexander Dec 9, 2020
349aa19
Removed auto help behavior present on web that's not used on mobile.
jd-alexander Dec 9, 2020
04a39b4
Merge branch 'master' into rnmobile/audio-block-I-b
jd-alexander Dec 9, 2020
32029e0
[Android] Wired the click of the Audio Media Library button.
jd-alexander Dec 16, 2020
a18b8ac
Added Audio media options for choosing audio file locally.
jd-alexander Dec 16, 2020
af6cb99
[RNMobile] Audio Block: Proper caption field (#27689)
ceyhun Dec 17, 2020
193339f
Add alert prompt to insert from URL
ceyhun Dec 18, 2020
4ab2988
Set entered URL in audio block attributes
ceyhun Dec 18, 2020
d9a6041
Merge branch 'master' into rnmobile/audio-block-I-b
jd-alexander Jan 7, 2021
1a46994
Merge branch 'master' into rnmobile/audio-block-I-b
jd-alexander Jan 14, 2021
f09c955
Merge branch 'master' into rnmobile/audio-block-I-b
jd-alexander Jan 18, 2021
fff09be
initial integration with react native prompt.
jd-alexander Jan 20, 2021
d4209e8
updated prompt lib.
jd-alexander Jan 20, 2021
9d61d49
Merge branch 'rnmobile/audio-block-I-b' into rnmobile/audio-block-IV-…
jd-alexander Jan 20, 2021
f0a1034
updated commit hash of prompt lib.
jd-alexander Jan 20, 2021
1eb58d2
Updated package-lock.json.
jd-alexander Jan 20, 2021
17dea27
Added RNPromptPackage to Glue Code.
jd-alexander Jan 20, 2021
c7154d3
Merge branch 'master' into rnmobile/audio-block-IV-from-url
jd-alexander Feb 18, 2021
0f597f3
fixed merge conflicts between the edit.native.js files of the branches
jd-alexander Feb 18, 2021
e4dec03
added onSelectURL to the media-upload component
jd-alexander Feb 20, 2021
f77a861
added onSelectURL to the media-placeholder
jd-alexander Feb 20, 2021
cad8e8a
updated onSelectURL support with notice and URL validation
jd-alexander Feb 20, 2021
ef478bb
sync package-lock.json
jd-alexander Feb 20, 2021
ee9a536
Merge remote-tracking branch 'origin/master' into rnmobile/audio-bloc…
jd-alexander Feb 23, 2021
6b6221f
updated package-lock.json
jd-alexander Feb 23, 2021
377ceae
updated package-lock.json
jd-alexander Feb 23, 2021
01242f5
Merge branch 'trunk' into rnmobile/audio-block-IV-from-url
jd-alexander Apr 7, 2021
5911b09
updated react-native-prompt-android setup due to binary dep changes.
jd-alexander Apr 7, 2021
cebdf5f
sync package-lock.json
jd-alexander Apr 7, 2021
2dd3b6c
Integrated RNPromptPackage with the glue code.
jd-alexander Apr 7, 2021
f348df3
sync package-lock.json
jd-alexander Apr 7, 2021
b81dd77
package-lock.json fix
jd-alexander Apr 7, 2021
d4ad088
sync package-lock.json
jd-alexander Apr 8, 2021
754b999
Added the globe icon to the Insert from URL source.Only shown on Android
jd-alexander Apr 8, 2021
e7ab21b
Extract filename from all URL types and optimized extension logic.
jd-alexander Apr 20, 2021
1834b58
Merge branch 'trunk' into rnmobile/audio-block-IV-from-url
jd-alexander Apr 20, 2021
614d57b
Merge branch 'trunk' into rnmobile/audio-block-IV-from-url
jd-alexander Apr 29, 2021
6170600
Merge branch 'trunk' into rnmobile/audio-block-IV-from-url
jd-alexander May 13, 2021
1e550e6
Merge branch 'trunk' into rnmobile/audio-block-IV-from-url
jd-alexander May 19, 2021
e68550e
Reduced onPress -> onSelectURL logic since the parameters match.
jd-alexander May 19, 2021
024ecad
Added entry to CHANGELOG.md
jd-alexander May 19, 2021
1a07c23
Merge branch 'trunk' into rnmobile/audio-block-IV-from-url
jd-alexander May 21, 2021
c428aa5
Fixed release notes entry.
jd-alexander May 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function MediaPlaceholder( props ) {
backgroundColor,
hideContent,
autoOpenMediaUpload,
onSelectURL,
} = props;

// use ref to keep media array current for callbacks during rerenders
Expand Down Expand Up @@ -156,6 +157,7 @@ function MediaPlaceholder( props ) {
<MediaUpload
allowedTypes={ allowedTypes }
onSelect={ setMedia }
onSelectURL={ onSelectURL }
__experimentalOnlyMediaLibrary={
__experimentalOnlyMediaLibrary
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Platform } from 'react-native';

import { delay } from 'lodash';

import prompt from 'react-native-prompt-android';

/**
* WordPress dependencies
*/
Expand All @@ -22,6 +24,7 @@ import {
image,
wordpress,
mobile,
globe,
} from '@wordpress/icons';

export const MEDIA_TYPE_IMAGE = 'image';
Expand Down Expand Up @@ -111,11 +114,20 @@ export class MediaUpload extends Component {
mediaLibrary: true,
};

const urlSource = {
id: 'URL',
value: 'URL',
label: __( 'Insert from URL' ),
types: [ MEDIA_TYPE_AUDIO ],
icon: globe,
};

const internalSources = [
deviceLibrarySource,
cameraImageSource,
cameraVideoSource,
siteLibrarySource,
urlSource,
];

return internalSources.concat( this.state.otherMediaOptions );
Expand Down Expand Up @@ -166,7 +178,34 @@ export class MediaUpload extends Component {
}

onPickerSelect( value ) {
const { allowedTypes = [], onSelect, multiple = false } = this.props;
const {
allowedTypes = [],
onSelect,
onSelectURL,
multiple = false,
} = this.props;

if ( value === 'URL' ) {
prompt(
__( 'Type a URL' ), // title
undefined, // message
[
{
text: __( 'Cancel' ),
style: 'cancel',
},
{
text: __( 'Apply' ),
onPress: onSelectURL,
},
], // buttons
'plain-text', // type
undefined, // defaultValue
'url' // keyboardType
);
return;
}

const mediaSource = this.getAllSources()
.filter( ( source ) => source.value === value )
.shift();
Expand Down
13 changes: 10 additions & 3 deletions packages/block-library/src/audio/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { audio as icon, replace } from '@wordpress/icons';
import { useState } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
import { store as noticesStore } from '@wordpress/notices';
import { isURL } from '@wordpress/url';

/**
* Internal dependencies
Expand Down Expand Up @@ -75,8 +76,14 @@ function AudioEdit( {
};
}

function onSelectURL() {
// TODO: Set up add audio from URL flow
function onSelectURL( newSrc ) {
if ( newSrc !== src ) {
if ( isURL( newSrc ) ) {
setAttributes( { src: newSrc, id: undefined } );
} else {
createErrorNotice( __( 'Invalid URL. Audio file not found.' ) );
}
}
}

function onSelectAudio( media ) {
Expand Down Expand Up @@ -136,7 +143,6 @@ function AudioEdit( {
return (
<MediaUploadProgress
mediaId={ id }
onUpdateMediaProgress={ this.updateMediaProgress }
onFinishMediaUploadWithSuccess={ onFileChange }
onFinishMediaUploadWithFailure={ onError }
onMediaUploadStateReset={ onFileChange }
Expand Down Expand Up @@ -211,6 +217,7 @@ function AudioEdit( {
allowedTypes={ ALLOWED_MEDIA_TYPES }
isReplacingMedia={ true }
onSelect={ onSelectAudio }
onSelectURL={ onSelectURL }
render={ ( { open, getMediaOptions } ) => {
return getBlockUI( open, getMediaOptions );
} }
Expand Down
12 changes: 9 additions & 3 deletions packages/components/src/mobile/audio-player/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,15 @@ function Player( {

if ( src ) {
const decodedURI = safeDecodeURI( src );
const fileName = decodedURI.split( '/' ).pop();
const fileName = decodedURI
.split( '#' )
.shift()
.split( '?' )
.shift()
.split( '/' )
.pop();
const parts = fileName.split( '.' );
extension = parts.pop().toUpperCase();
extension = parts.length === 2 ? parts.pop().toUpperCase() + ' ' : '';
jd-alexander marked this conversation as resolved.
Show resolved Hide resolved
title = parts.join( '.' );
}

Expand All @@ -144,7 +150,7 @@ function Player( {
return (
extension +
// translators: displays audio file extension. e.g. MP3 audio file
__( ' audio file' )
__( 'audio file' )
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ dependencies {
implementation "com.github.wordpress-mobile:react-native-screens:${readHashedVersion('../../../react-native-editor/package.json', 'react-native-screens', 'dependencies')}"
implementation "com.github.wordpress-mobile:react-native-safe-area-context:${readHashedVersion('../../../react-native-editor/package.json', 'react-native-safe-area-context', 'dependencies')}"
implementation "com.github.wordpress-mobile:react-native-reanimated:${readHashedVersion('../../../react-native-editor/package.json', 'react-native-reanimated', 'dependencies')}"
implementation "com.github.wordpress-mobile:react-native-prompt-android:${readHashedVersion('../../../react-native-editor/package.json', 'react-native-prompt-android', 'dependencies')}"
runtimeOnly "org.wordpress-mobile:hermes-release-mirror:0.61.5"
} else {
api 'com.facebook.react:react-native:+'
Expand All @@ -104,6 +105,7 @@ dependencies {
api project(':react-native-screens')
api project(':react-native-safe-area-context')
api project(':react-native-reanimated')
api project(':react-native-prompt-android')
debugRuntimeOnly "org.wordpress-mobile:hermes-debug-mirror:0.61.5"
releaseRuntimeOnly "org.wordpress-mobile:hermes-release-mirror:0.61.5"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import im.shimo.react.prompt.RNPromptPackage;
import okhttp3.OkHttpClient;


Expand Down Expand Up @@ -488,6 +489,7 @@ public void requestFocalPointPickerTooltipShown(FocalPointPickerTooltipShownCall
new SafeAreaContextPackage(),
new RNCMaskedViewPackage(),
new ReanimatedPackage(),
new RNPromptPackage(),
mRnReactNativeGutenbergBridgePackage);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-bridge/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ include ':react-native-safe-area-context'
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-safe-area-context/android')
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-reanimated/android')
include ':react-native-prompt-android'
project(':react-native-prompt-android').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-prompt-android/android')

3 changes: 2 additions & 1 deletion packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ For each user feature we should also add a importance categorization label to i

## Unreleased

- [*] Audio block: Add Insert from URL functionality. [#27817]

## 1.53.0

- [*] Bottom-sheet: Add custom header [#30291]
Expand All @@ -19,7 +21,6 @@ For each user feature we should also add a importance categorization label to i
- [***] Add reusable blocks to the inserter menu. [#28495]
- [*] The BottomSheet Cell component now supports the help prop so that a hint can be supplied to all Cell based components. [#30885]


## 1.52.2

- [*] Disabled featured image banner on iOS. [#31681]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import java.util.List;
import java.util.ArrayList;

import im.shimo.react.prompt.RNPromptPackage;

public class MainApplication extends Application implements ReactApplication, GutenbergBridgeInterface {

private static final String TAG = "MainApplication";
Expand Down Expand Up @@ -258,6 +260,7 @@ protected List<ReactPackage> getPackages() {
new ReanimatedPackage(),
new SafeAreaContextPackage(),
new RNScreensPackage(),
new RNPromptPackage(),
mRnReactNativeGutenbergBridgePackage);
}

Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"react-native-keyboard-aware-scroll-view": "git+https://github.com/wordpress-mobile/react-native-keyboard-aware-scroll-view.git#gb-v0.8.8",
"react-native-linear-gradient": "git+https://github.com/wordpress-mobile/react-native-linear-gradient.git#52bf43077171cff8714ce3e0155f3ebb7f55bc37",
"react-native-modal": "^6.5.0",
"react-native-prompt-android": "git+https://github.com/wordpress-mobile/react-native-prompt-android.git#aba780c0bacddca76bff2c470a6c1d1d760b0b55",
"react-native-reanimated": "git+https://github.com/wordpress-mobile/react-native-reanimated.git#ed48f510fba751cd75da7629e92276166766be91",
"react-native-safe-area": "^0.5.0",
"react-native-safe-area-context": "git+https://github.com/wordpress-mobile/react-native-safe-area-context.git#1e3c0d34f31b59fb79f71ec0b4c39c513f684871",
Expand Down