From 4527c2728f89231ac5ef62452b3a53e7375e7874 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 19 Oct 2020 22:13:34 -0400 Subject: [PATCH 01/26] Update gb-mobile reference --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 9f2615778c98..6fa4dedbd621 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 9f2615778c9868643d756047424725f0e7828a74 +Subproject commit 6fa4dedbd621a8b324ec0762e218ea1f9d941dd6 From bdd34a75e8c2210df9d1a6dcd9fc07651857948e Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 20 Oct 2020 19:53:42 -0400 Subject: [PATCH 02/26] Update gb-mobile reference --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 6fa4dedbd621..9cb9d86b0012 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 6fa4dedbd621a8b324ec0762e218ea1f9d941dd6 +Subproject commit 9cb9d86b0012b71531de546ff6689f398814e23e From 661c94cbae2f203478c140441a4564fa35be900b Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 20 Oct 2020 19:54:44 -0400 Subject: [PATCH 03/26] Add support for document files --- .../gutenberg/GutenbergEditorFragment.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index c525fff0bf60..ed1754a72cfc 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -90,6 +90,7 @@ public class GutenbergEditorFragment extends EditorFragmentAbstract implements private static final int CAPTURE_PHOTO_PERMISSION_REQUEST_CODE = 101; private static final int CAPTURE_VIDEO_PERMISSION_REQUEST_CODE = 102; + private static final String MEDIA_SOURCE_DOCUMENT = "MEDIA_SOURCE_DOCUMENT"; private static final String MEDIA_SOURCE_STOCK_MEDIA = "MEDIA_SOURCE_STOCK_MEDIA"; private static final String GIF_MEDIA = "GIF_MEDIA"; @@ -252,12 +253,20 @@ public ArrayList onGetOtherMediaImageOptions() { return otherMediaImageOptions; } + @Override + public ArrayList onGetOtherMediaDocumentOptions() { + ArrayList otherMediaDocumentOptions = initOtherMediaDocumentOptions(); + return otherMediaDocumentOptions; + } + @Override public void onOtherMediaButtonClicked(String mediaSource, boolean allowMultipleSelection) { if (mediaSource.equals(MEDIA_SOURCE_STOCK_MEDIA)) { mEditorFragmentListener.onAddStockMediaClicked(allowMultipleSelection); } else if (mediaSource.equals(GIF_MEDIA)) { mEditorFragmentListener.onAddGifClicked(allowMultipleSelection); + } else if (mediaSource.equals(MEDIA_SOURCE_DOCUMENT)) { + mEditorFragmentListener.onAddDocumentClicked(allowMultipleSelection); } } }, @@ -457,6 +466,27 @@ private ArrayList initOtherMediaImageOptions() { return otherMediaOptions; } + private ArrayList initOtherMediaDocumentOptions() { + ArrayList otherMediaOptions = new ArrayList<>(); + + Bundle arguments = getArguments(); + FragmentActivity activity = getActivity(); + if (activity == null || arguments == null) { + AppLog.e(T.EDITOR, + "Failed to initialize other media options because the activity or getArguments() is null"); + return otherMediaOptions; + } + + String packageName = activity.getApplication().getPackageName(); + + int stockMediaResourceId = + getResources().getIdentifier("photo_picker_choose_file", "string", packageName); + + otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_DOCUMENT, getString(stockMediaResourceId))); + + return otherMediaOptions; + } + @Override public void onResume() { super.onResume(); @@ -889,7 +919,8 @@ public void appendMediaFiles(Map mediaList) { rnMediaList.add(createRNMediaUsingMimeType(mediaId, url, mediaEntry.getValue().getMimeType(), - mediaEntry.getValue().getCaption())); + mediaEntry.getValue().getCaption(), + mediaEntry.getValue().getTitle())); } getGutenbergContainerFragment().appendMediaFiles(rnMediaList); From b6d44c8733b840495c237c8ce9c3456c5ee5be45 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 20 Oct 2020 19:56:07 -0400 Subject: [PATCH 04/26] Upload selected document files --- .../wordpress/android/ui/posts/EditPostActivity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index b54b5d41b072..98aec6c00c91 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2656,6 +2656,13 @@ postId, getSite(), mediaUri, mOnGetMentionResult = null; } break; + case RequestCodes.FILE_LIBRARY: + List documentUris = WPMediaUtils.retrieveMediaUris(data); + //mImageEditorTracker.trackAddPhoto(uris); + for (Uri item : documentUris) { + mEditorMedia.addNewMediaToEditorAsync(item, true); + } + break; } } @@ -2893,6 +2900,11 @@ public void onAddGifClicked(boolean allowMultipleSelection) { onPhotoPickerIconClicked(PhotoPickerIcon.GIF, allowMultipleSelection); } + @Override + public void onAddDocumentClicked(boolean allowMultipleSelection) { + mMediaPickerLauncher.showDocumentPicker(this, allowMultipleSelection); + } + @Override public void onPerformFetch(String path, Consumer onResult, Consumer onError) { if (mSite != null) { From c9028f9aad74e06ed8f23b564771943789b71176 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 20 Oct 2020 20:05:57 -0400 Subject: [PATCH 05/26] Enable consolidated media picker --- WordPress/build.gradle | 2 +- .../wordpress/android/ui/RequestCodes.java | 1 + .../ui/photopicker/MediaPickerLauncher.kt | 29 +++++++++++++++++++ .../android/ui/posts/EditPostActivity.java | 2 +- .../editor/EditorFragmentAbstract.java | 1 + 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 4acf1224e1af..118db5bcb122 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -74,7 +74,7 @@ android { buildConfigField "boolean", "UNIFIED_LOGIN_AVAILABLE", "true" buildConfigField "boolean", "WP_STORIES_AVAILABLE", "true" buildConfigField "boolean", "ANY_FILE_UPLOAD", "true" - buildConfigField "boolean", "CONSOLIDATED_MEDIA_PICKER", "false" + buildConfigField "boolean", "CONSOLIDATED_MEDIA_PICKER", "true" buildConfigField "boolean", "ENABLE_FEATURE_CONFIGURATION", "true" } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java b/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java index 30e5e832822e..7a13d69b97b0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java @@ -43,6 +43,7 @@ public class RequestCodes { public static final int MULTI_SELECT_MEDIA_PICKER = 2600; public static final int SINGLE_SELECT_MEDIA_PICKER = 2601; public static final int MEDIA_SETTINGS = 2700; + public static final int DOCUMENT_LIBRARY = 2800; // Jetpack public static final int REQUEST_JETPACK = 3000; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt index fcc591729afc..66bd94fe81e1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt @@ -194,6 +194,35 @@ class MediaPickerLauncher @Inject constructor( } } + fun showDocumentPicker(activity: Activity, canMultiselect: Boolean) { + if (consolidatedMediaPickerFeatureConfig.isEnabled()) { + val allowedTypes = mutableSetOf(DOCUMENT) + val mediaPickerSetup = MediaPickerSetup( + primaryDataSource = DEVICE, + availableDataSources = setOf(), + canMultiselect = canMultiselect, + requiresStoragePermissions = true, + allowedTypes = allowedTypes, + cameraSetup = HIDDEN, + systemPickerEnabled = true, + editingEnabled = true, + queueResults = false, + defaultSearchView = false, + title = R.string.photo_picker_choose_file + ) + val intent = MediaPickerActivity.buildIntent( + activity, + mediaPickerSetup + ) + activity.startActivityForResult( + intent, + RequestCodes.DOCUMENT_LIBRARY + ) + } else { + WPMediaUtils.launchFileLibrary(activity, true) + } + } + fun viewWPMediaLibraryPickerForResult(activity: Activity, site: SiteModel, browserType: MediaBrowserType) { if (consolidatedMediaPickerFeatureConfig.isEnabled()) { val intent = MediaPickerActivity.buildIntent( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 98aec6c00c91..b6654f48554d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2656,7 +2656,7 @@ postId, getSite(), mediaUri, mOnGetMentionResult = null; } break; - case RequestCodes.FILE_LIBRARY: + case RequestCodes.DOCUMENT_LIBRARY: List documentUris = WPMediaUtils.retrieveMediaUris(data); //mImageEditorTracker.trackAddPhoto(uris); for (Uri item : documentUris) { diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java index eccf9727ac94..d27dd5e7d629 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java @@ -199,6 +199,7 @@ public interface EditorFragmentListener extends DialogVisibilityProvider { void onHtmlModeToggledInToolbar(); void onAddStockMediaClicked(boolean allowMultipleSelection); void onAddGifClicked(boolean allowMultipleSelection); + void onAddDocumentClicked(boolean allowMultipleSelection); void onPerformFetch(String path, Consumer onResult, Consumer onError); void onGutenbergEditorSessionTemplateApplyTracked(String template); void onGutenbergEditorSessionTemplatePreviewTracked(String template); From af82450660a1c0d04ea7cbd563b006b76c3ff908 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 20 Oct 2020 20:22:57 -0400 Subject: [PATCH 06/26] Fix lint error --- .../java/org/wordpress/android/ui/posts/EditPostActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index b6654f48554d..ed8316c1f70e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2658,7 +2658,7 @@ postId, getSite(), mediaUri, break; case RequestCodes.DOCUMENT_LIBRARY: List documentUris = WPMediaUtils.retrieveMediaUris(data); - //mImageEditorTracker.trackAddPhoto(uris); + // ToDo track added file e.g. mImageEditorTracker.trackAddPhoto(uris); for (Uri item : documentUris) { mEditorMedia.addNewMediaToEditorAsync(item, true); } From 9957e0f52dd2ed4ddb14273fdaca4fc80eccaba5 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 27 Oct 2020 13:57:48 -0400 Subject: [PATCH 07/26] Fix crash on Android and add tracking of document --- .../wordpress/android/ui/posts/EditPostActivity.java | 11 +++++++---- .../wordpress/android/analytics/AnalyticsTracker.java | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index ed8316c1f70e..41a8f0863ebb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2657,10 +2657,13 @@ postId, getSite(), mediaUri, } break; case RequestCodes.DOCUMENT_LIBRARY: - List documentUris = WPMediaUtils.retrieveMediaUris(data); - // ToDo track added file e.g. mImageEditorTracker.trackAddPhoto(uris); - for (Uri item : documentUris) { - mEditorMedia.addNewMediaToEditorAsync(item, true); + if (data.hasExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)) { + uris = convertStringArrayIntoUrisList( + data.getStringArrayExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)); + for (Uri item : uris) { + mEditorMedia.addNewMediaToEditorAsync(item, true); + mAnalyticsTrackerWrapper.track(Stat.EDITOR_ADDED_DOCUMENT_VIA_LIBRARY); + } } break; } diff --git a/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java b/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java index 5404b5ea402c..641feac47e95 100644 --- a/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java +++ b/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java @@ -137,6 +137,7 @@ public enum Stat { EDITOR_ADDED_PHOTO_VIA_WP_MEDIA_LIBRARY, EDITOR_ADDED_VIDEO_VIA_WP_MEDIA_LIBRARY, EDITOR_ADDED_PHOTO_VIA_STOCK_MEDIA_LIBRARY, + EDITOR_ADDED_DOCUMENT_VIA_LIBRARY, MEDIA_PHOTO_OPTIMIZED, MEDIA_PHOTO_OPTIMIZE_ERROR, MEDIA_VIDEO_OPTIMIZED, From 8de336a56f0aff2cbdfece10a4985442bc455e90 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 27 Oct 2020 16:06:30 -0400 Subject: [PATCH 08/26] Use native picker library --- .../android/ui/posts/EditPostActivity.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 41a8f0863ebb..1718b9ded289 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2656,14 +2656,11 @@ postId, getSite(), mediaUri, mOnGetMentionResult = null; } break; - case RequestCodes.DOCUMENT_LIBRARY: - if (data.hasExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)) { - uris = convertStringArrayIntoUrisList( - data.getStringArrayExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)); - for (Uri item : uris) { - mEditorMedia.addNewMediaToEditorAsync(item, true); - mAnalyticsTrackerWrapper.track(Stat.EDITOR_ADDED_DOCUMENT_VIA_LIBRARY); - } + case RequestCodes.FILE_LIBRARY: + uris = WPMediaUtils.retrieveMediaUris(data); + mAnalyticsTrackerWrapper.track(Stat.EDITOR_ADDED_DOCUMENT_VIA_LIBRARY); + for (Uri item : uris) { + mEditorMedia.addNewMediaToEditorAsync(item, false); } break; } @@ -2905,7 +2902,7 @@ public void onAddGifClicked(boolean allowMultipleSelection) { @Override public void onAddDocumentClicked(boolean allowMultipleSelection) { - mMediaPickerLauncher.showDocumentPicker(this, allowMultipleSelection); + WPMediaUtils.launchFileLibrary(this, allowMultipleSelection); } @Override From f4a1401e35ccdb88afb87adfd494778aca9766c8 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 27 Oct 2020 16:10:44 -0400 Subject: [PATCH 09/26] remove unused request code --- .../src/main/java/org/wordpress/android/ui/RequestCodes.java | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java b/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java index 7a13d69b97b0..30e5e832822e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/RequestCodes.java @@ -43,7 +43,6 @@ public class RequestCodes { public static final int MULTI_SELECT_MEDIA_PICKER = 2600; public static final int SINGLE_SELECT_MEDIA_PICKER = 2601; public static final int MEDIA_SETTINGS = 2700; - public static final int DOCUMENT_LIBRARY = 2800; // Jetpack public static final int REQUEST_JETPACK = 3000; From f7b99a12481ed333c0c37aca95d99878f7fec524 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 27 Oct 2020 16:34:56 -0400 Subject: [PATCH 10/26] Remove unused code --- WordPress/build.gradle | 2 +- .../ui/photopicker/MediaPickerLauncher.kt | 29 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 118db5bcb122..4acf1224e1af 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -74,7 +74,7 @@ android { buildConfigField "boolean", "UNIFIED_LOGIN_AVAILABLE", "true" buildConfigField "boolean", "WP_STORIES_AVAILABLE", "true" buildConfigField "boolean", "ANY_FILE_UPLOAD", "true" - buildConfigField "boolean", "CONSOLIDATED_MEDIA_PICKER", "true" + buildConfigField "boolean", "CONSOLIDATED_MEDIA_PICKER", "false" buildConfigField "boolean", "ENABLE_FEATURE_CONFIGURATION", "true" } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt index 66bd94fe81e1..fcc591729afc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/MediaPickerLauncher.kt @@ -194,35 +194,6 @@ class MediaPickerLauncher @Inject constructor( } } - fun showDocumentPicker(activity: Activity, canMultiselect: Boolean) { - if (consolidatedMediaPickerFeatureConfig.isEnabled()) { - val allowedTypes = mutableSetOf(DOCUMENT) - val mediaPickerSetup = MediaPickerSetup( - primaryDataSource = DEVICE, - availableDataSources = setOf(), - canMultiselect = canMultiselect, - requiresStoragePermissions = true, - allowedTypes = allowedTypes, - cameraSetup = HIDDEN, - systemPickerEnabled = true, - editingEnabled = true, - queueResults = false, - defaultSearchView = false, - title = R.string.photo_picker_choose_file - ) - val intent = MediaPickerActivity.buildIntent( - activity, - mediaPickerSetup - ) - activity.startActivityForResult( - intent, - RequestCodes.DOCUMENT_LIBRARY - ) - } else { - WPMediaUtils.launchFileLibrary(activity, true) - } - } - fun viewWPMediaLibraryPickerForResult(activity: Activity, site: SiteModel, browserType: MediaBrowserType) { if (consolidatedMediaPickerFeatureConfig.isEnabled()) { val intent = MediaPickerActivity.buildIntent( From a856bac53caaabea6a269e2400129a723d3758e6 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 27 Oct 2020 17:18:33 -0400 Subject: [PATCH 11/26] rename document to file in all appearances --- .../org/wordpress/android/ui/posts/EditPostActivity.java | 4 ++-- .../org/wordpress/android/analytics/AnalyticsTracker.java | 2 +- .../wordpress/android/editor/EditorFragmentAbstract.java | 2 +- .../android/editor/gutenberg/GutenbergEditorFragment.java | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 33428c5d5b37..503cdbbe5b04 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2658,7 +2658,7 @@ postId, getSite(), mediaUri, break; case RequestCodes.FILE_LIBRARY: uris = WPMediaUtils.retrieveMediaUris(data); - mAnalyticsTrackerWrapper.track(Stat.EDITOR_ADDED_DOCUMENT_VIA_LIBRARY); + mAnalyticsTrackerWrapper.track(Stat.EDITOR_ADDED_FILE_VIA_LIBRARY); for (Uri item : uris) { mEditorMedia.addNewMediaToEditorAsync(item, false); } @@ -2911,7 +2911,7 @@ public void onAddGifClicked(boolean allowMultipleSelection) { } @Override - public void onAddDocumentClicked(boolean allowMultipleSelection) { + public void onAddFileClicked(boolean allowMultipleSelection) { WPMediaUtils.launchFileLibrary(this, allowMultipleSelection); } diff --git a/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java b/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java index ef429f23592f..ed97ba023deb 100644 --- a/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java +++ b/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java @@ -139,7 +139,7 @@ public enum Stat { EDITOR_ADDED_PHOTO_VIA_WP_MEDIA_LIBRARY, EDITOR_ADDED_VIDEO_VIA_WP_MEDIA_LIBRARY, EDITOR_ADDED_PHOTO_VIA_STOCK_MEDIA_LIBRARY, - EDITOR_ADDED_DOCUMENT_VIA_LIBRARY, + EDITOR_ADDED_FILE_VIA_LIBRARY, MEDIA_PHOTO_OPTIMIZED, MEDIA_PHOTO_OPTIMIZE_ERROR, MEDIA_VIDEO_OPTIMIZED, diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java index d27dd5e7d629..ef0ffd325643 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java @@ -199,7 +199,7 @@ public interface EditorFragmentListener extends DialogVisibilityProvider { void onHtmlModeToggledInToolbar(); void onAddStockMediaClicked(boolean allowMultipleSelection); void onAddGifClicked(boolean allowMultipleSelection); - void onAddDocumentClicked(boolean allowMultipleSelection); + void onAddFileClicked(boolean allowMultipleSelection); void onPerformFetch(String path, Consumer onResult, Consumer onError); void onGutenbergEditorSessionTemplateApplyTracked(String template); void onGutenbergEditorSessionTemplatePreviewTracked(String template); diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index ed1754a72cfc..2e52358d82ad 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -90,7 +90,7 @@ public class GutenbergEditorFragment extends EditorFragmentAbstract implements private static final int CAPTURE_PHOTO_PERMISSION_REQUEST_CODE = 101; private static final int CAPTURE_VIDEO_PERMISSION_REQUEST_CODE = 102; - private static final String MEDIA_SOURCE_DOCUMENT = "MEDIA_SOURCE_DOCUMENT"; + private static final String MEDIA_SOURCE_FILE = "MEDIA_SOURCE_FILE"; private static final String MEDIA_SOURCE_STOCK_MEDIA = "MEDIA_SOURCE_STOCK_MEDIA"; private static final String GIF_MEDIA = "GIF_MEDIA"; @@ -265,8 +265,8 @@ public void onOtherMediaButtonClicked(String mediaSource, boolean allowMultipleS mEditorFragmentListener.onAddStockMediaClicked(allowMultipleSelection); } else if (mediaSource.equals(GIF_MEDIA)) { mEditorFragmentListener.onAddGifClicked(allowMultipleSelection); - } else if (mediaSource.equals(MEDIA_SOURCE_DOCUMENT)) { - mEditorFragmentListener.onAddDocumentClicked(allowMultipleSelection); + } else if (mediaSource.equals(MEDIA_SOURCE_FILE)) { + mEditorFragmentListener.onAddFileClicked(allowMultipleSelection); } } }, @@ -482,7 +482,7 @@ private ArrayList initOtherMediaDocumentOptions() { int stockMediaResourceId = getResources().getIdentifier("photo_picker_choose_file", "string", packageName); - otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_DOCUMENT, getString(stockMediaResourceId))); + otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_FILE, getString(stockMediaResourceId))); return otherMediaOptions; } From c06f5824272bda3e11ca1de4c4378c42c08958f4 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 27 Oct 2020 17:27:34 -0400 Subject: [PATCH 12/26] rename document to file in all appearances --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 2e52358d82ad..fe6f50e34dec 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -254,8 +254,8 @@ public ArrayList onGetOtherMediaImageOptions() { } @Override - public ArrayList onGetOtherMediaDocumentOptions() { - ArrayList otherMediaDocumentOptions = initOtherMediaDocumentOptions(); + public ArrayList onGetOtherMediaFileOptions() { + ArrayList otherMediaDocumentOptions = initOtherMediaFileOptions(); return otherMediaDocumentOptions; } @@ -466,7 +466,7 @@ private ArrayList initOtherMediaImageOptions() { return otherMediaOptions; } - private ArrayList initOtherMediaDocumentOptions() { + private ArrayList initOtherMediaFileOptions() { ArrayList otherMediaOptions = new ArrayList<>(); Bundle arguments = getArguments(); From 91d89c1975c051d1e0b284c5b6385ee4ba634d4b Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 27 Oct 2020 17:27:44 -0400 Subject: [PATCH 13/26] update gb mobile reference --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 9cb9d86b0012..a8d5e9369c21 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 9cb9d86b0012b71531de546ff6689f398814e23e +Subproject commit a8d5e9369c21b2f9a4f3b90840aeba91343357d1 From f85da5bc146dba9b78b317480e3f923e7de44957 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 2 Nov 2020 13:56:01 -0500 Subject: [PATCH 14/26] Add proper case in getEventNameForStat for EDITOR_ADDED_FILE_VIA_LIBRARY --- .../org/wordpress/android/analytics/AnalyticsTrackerNosara.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java b/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java index 143e42dd3bde..6093b5d490ba 100644 --- a/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java +++ b/libs/analytics/WordPressAnalytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java @@ -793,6 +793,8 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) { return "editor_video_added"; case EDITOR_ADDED_PHOTO_VIA_STOCK_MEDIA_LIBRARY: return "editor_photo_added"; + case EDITOR_ADDED_FILE_VIA_LIBRARY: + return "editor_file_added"; case MEDIA_PHOTO_OPTIMIZED: return "media_photo_optimized"; case MEDIA_PHOTO_OPTIMIZE_ERROR: From 39bcb3f58ae96a4399be064d3304e52fb98de8a2 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 2 Nov 2020 14:09:03 -0500 Subject: [PATCH 15/26] Convert media source statement to switch block --- .../gutenberg/GutenbergEditorFragment.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index fe6f50e34dec..9970e16f6056 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -261,12 +261,16 @@ public ArrayList onGetOtherMediaFileOptions() { @Override public void onOtherMediaButtonClicked(String mediaSource, boolean allowMultipleSelection) { - if (mediaSource.equals(MEDIA_SOURCE_STOCK_MEDIA)) { - mEditorFragmentListener.onAddStockMediaClicked(allowMultipleSelection); - } else if (mediaSource.equals(GIF_MEDIA)) { - mEditorFragmentListener.onAddGifClicked(allowMultipleSelection); - } else if (mediaSource.equals(MEDIA_SOURCE_FILE)) { - mEditorFragmentListener.onAddFileClicked(allowMultipleSelection); + switch (mediaSource) { + case MEDIA_SOURCE_STOCK_MEDIA: + mEditorFragmentListener.onAddStockMediaClicked(allowMultipleSelection); + case GIF_MEDIA: + mEditorFragmentListener.onAddGifClicked(allowMultipleSelection); + case MEDIA_SOURCE_FILE: + mEditorFragmentListener.onAddFileClicked(allowMultipleSelection); + default: + AppLog.e(T.EDITOR, + "Unsupported media source " + mediaSource); } } }, From d04776cfd63593913f1bb90485e64b60e806811a Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 2 Nov 2020 14:12:03 -0500 Subject: [PATCH 16/26] Update libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java Co-authored-by: Joel Dean --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 9970e16f6056..03d8cda4cad6 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -483,7 +483,7 @@ private ArrayList initOtherMediaFileOptions() { String packageName = activity.getApplication().getPackageName(); - int stockMediaResourceId = + int chooseFileResourceId = getResources().getIdentifier("photo_picker_choose_file", "string", packageName); otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_FILE, getString(stockMediaResourceId))); From 822cc6e15273a38f9b48eab11c25440112ed87d0 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 2 Nov 2020 14:12:52 -0500 Subject: [PATCH 17/26] Fix renaming suggestion. --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 03d8cda4cad6..bc77e5540d1e 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -486,7 +486,7 @@ private ArrayList initOtherMediaFileOptions() { int chooseFileResourceId = getResources().getIdentifier("photo_picker_choose_file", "string", packageName); - otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_FILE, getString(stockMediaResourceId))); + otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_FILE, getString(chooseFileResourceId))); return otherMediaOptions; } From ffa5f7d8c3ad5818c99ed288dfc14b54f7a30aa8 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Mon, 2 Nov 2020 14:18:38 -0500 Subject: [PATCH 18/26] Add break to switch case --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index bc77e5540d1e..e18beba0cc38 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -264,10 +264,13 @@ public void onOtherMediaButtonClicked(String mediaSource, boolean allowMultipleS switch (mediaSource) { case MEDIA_SOURCE_STOCK_MEDIA: mEditorFragmentListener.onAddStockMediaClicked(allowMultipleSelection); + break; case GIF_MEDIA: mEditorFragmentListener.onAddGifClicked(allowMultipleSelection); + break; case MEDIA_SOURCE_FILE: mEditorFragmentListener.onAddFileClicked(allowMultipleSelection); + break; default: AppLog.e(T.EDITOR, "Unsupported media source " + mediaSource); From 11c593e03184f054c885b0029c5d4769b6e4456b Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Thu, 12 Nov 2020 10:25:12 -0500 Subject: [PATCH 19/26] remove unnecessary check if arguments are null --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 55489dde7642..eec29b2ae6d0 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -524,9 +524,9 @@ private ArrayList initOtherMediaFileOptions() { Bundle arguments = getArguments(); FragmentActivity activity = getActivity(); - if (activity == null || arguments == null) { + if (activity == null) { AppLog.e(T.EDITOR, - "Failed to initialize other media options because the activity or getArguments() is null"); + "Failed to initialize other media options because the activity is null"); return otherMediaOptions; } From 741fb4de8b871a7380c2a402dc3527e2635b8df9 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Thu, 12 Nov 2020 10:28:12 -0500 Subject: [PATCH 20/26] Align naming --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index eec29b2ae6d0..e36907194316 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -266,8 +266,8 @@ public ArrayList onGetOtherMediaImageOptions() { @Override public ArrayList onGetOtherMediaFileOptions() { - ArrayList otherMediaDocumentOptions = initOtherMediaFileOptions(); - return otherMediaDocumentOptions; + ArrayList otherMediaFileOptionsOptions = initOtherMediaFileOptions(); + return otherMediaFileOptionsOptions; } @Override From 59ff6c9bcd9d15ad73e05f5dd37809698521cb46 Mon Sep 17 00:00:00 2001 From: Joel Dean Date: Thu, 12 Nov 2020 15:04:43 -0500 Subject: [PATCH 21/26] Updated gutenberg ref --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index a8d5e9369c21..8cab0efe1aa2 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit a8d5e9369c21b2f9a4f3b90840aeba91343357d1 +Subproject commit 8cab0efe1aa2de1257dbd5131618028b2649b338 From 8d2b23c8540438c204cc56c340d0b04d75d6044d Mon Sep 17 00:00:00 2001 From: Joel Dean Date: Thu, 12 Nov 2020 15:35:34 -0500 Subject: [PATCH 22/26] Removed unneeded arguments and fixed typo --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index e36907194316..6344fe333ad2 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -266,8 +266,8 @@ public ArrayList onGetOtherMediaImageOptions() { @Override public ArrayList onGetOtherMediaFileOptions() { - ArrayList otherMediaFileOptionsOptions = initOtherMediaFileOptions(); - return otherMediaFileOptionsOptions; + ArrayList otherMediaFileOptions = initOtherMediaFileOptions(); + return otherMediaFileOptions; } @Override @@ -522,7 +522,6 @@ private ArrayList initOtherMediaImageOptions() { private ArrayList initOtherMediaFileOptions() { ArrayList otherMediaOptions = new ArrayList<>(); - Bundle arguments = getArguments(); FragmentActivity activity = getActivity(); if (activity == null) { AppLog.e(T.EDITOR, From d243c9e148b4a38c60e196e6ca192933f06873ac Mon Sep 17 00:00:00 2001 From: Joel Dean Date: Thu, 12 Nov 2020 17:12:47 -0500 Subject: [PATCH 23/26] Updated gutenberg ref --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 8cab0efe1aa2..9ab9e99f1e91 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 8cab0efe1aa2de1257dbd5131618028b2649b338 +Subproject commit 9ab9e99f1e9164719327bd8ab2a42dde39e70d34 From 3e07ac89232c0f4cd49f3f90706f5d439773ed4e Mon Sep 17 00:00:00 2001 From: eToledo Date: Fri, 13 Nov 2020 12:11:24 +0100 Subject: [PATCH 24/26] Update gutenberg ref --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 9ab9e99f1e91..6a46714951af 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 9ab9e99f1e9164719327bd8ab2a42dde39e70d34 +Subproject commit 6a46714951af882ea9c005a91badd5643633ba8e From a56f092ecc642266f901dbb3c1da84f1894ef9de Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Tue, 17 Nov 2020 14:37:03 +0100 Subject: [PATCH 25/26] Update Gutenberg ref --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 37ce251026f5..a622fb180033 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 37ce251026f5332b9ea53f0692104cc377617859 +Subproject commit a622fb18003377be08ab61677ef623104df5e718 From cd4b9a4db014f141b1e68a73f9b5bab83b6d7f22 Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Thu, 19 Nov 2020 10:18:26 +0100 Subject: [PATCH 26/26] Update Gutenberg ref --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index a622fb180033..24ea2e0f6a4d 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit a622fb18003377be08ab61677ef623104df5e718 +Subproject commit 24ea2e0f6a4dd1abbd77aea92217c1802c34c449