Skip to content

Commit

Permalink
Squashed 'libs/editor/' changes from eb069ba..7932116
Browse files Browse the repository at this point in the history
7932116 Merge pull request #448 from wordpress-mobile/issue/onConfigurationChanged-lint-error
6b58ec7 Update travis configuration
c1aedf6 call super onConfigurationChanged in ImageSettingsDialogFragment
f7cfaaa update gradle wrapper
17596a9 Update com.android.tools.build:gradle to 2.1.3
7c58485 Merge pull request #4421 from wordpress-mobile/update-dependencies
628a827 Adds a null check
4049834 Don't allow dropping web URLs
9eb9f06 Updating libraries to use correct/latest Utils
98ddad8 Updating the support library for all projects
fc899c1 Updating to build tools 24.0.1
dd77c0b Do allow dropping text while in HTML mode
88f3936 Disallow dropping images while in HTML mode
6b15049 Denote disallowed drop was indeed handled
4134df7 Toast the user about dropping images in Title
f2d6536 Revert "Padding instead of margins in editor editables"
5a2ec16 Support for dropping multiple images
d9cd10f Acquire permissions needed by the DragEvent
23df6de Padding instead of margins in editor editables
aba2bf7 Don't allow dropping images into the editor title
b2fb955 Use wp.loadText to reformat dropped text
f3eb205 Visually format the dropped text before inserting
8a4d420 Minor code re-org
e135ff0 Escape dropped text before inserting
65327ac Ensure initial paragraph tag on dropping text
687a261 Null check for dropped text
95f343a Handle text dropping directly in onDragListener
757a678 Fix: plain text drop uses a different getter
42a78b7 Support dropping PNGs
614dd2a Support for dropping text into the editor
347850d Move input caret while dragging
236aa2a Merge branch 'develop' into feature/drag-drop-editor
6ba9b0b Merge commit '8c64473541f2199f74480f309d2821c8018c79a1' into sync-editor-1.3
6729ac1 Merge branch 'hotfix/5.5.1' into release/5.6
2e60a4d rollback 23.4.0 versions of support libs in the editor
38c49d9 First stab at enabling drag-and-drop in editor
1fab16f Merge commit 'afb0de7a32b95bd121066088dc795f8a6e98909c' into hotfix/5.5.1
c137028 Merge commit 'ced263752a32fb381556cee59b6a2031f5b4f380' into hotfix/5.5.1
8a5cf08 Remove unused strings from the editor and merge them with the main strings.xml file for i18n
886f371 Merge branch 'release/5.5' into develop
e70d63e Merge commit 'd0d8dd46c2b8223d66ec3e80578788d1b6cd8b85' into release/5.5
f486891 Merge branch 'develop' into issue/3924-method-count
18a441c Merge branch 'release/5.5' into develop
4153312 Merge commit '49ac39827552c17c8d5b65eca236a55961cf6814' into release/5.5
ca22492 Merge commit '1cf141b3362c5c44f27a8b65775d3db27ac5756a' into release/5.5
4e5aad1 Merge branch 'release/5.5' into develop
a72f520 Merge commit '65eec31755233d054ff01bf729eea6d233f6d7df' into release/5.5
e3238bd Merge commit '2fc5d53d4ba45ed45c806a5ac0772458a4ef403e' into release/5.5
d1344dc update compileSdkVersion and buildToolsVersion in every subtrees
5faeba1 update gradle wrapper to 2.14
6223168 Merge pull request #4209 from wordpress-mobile/issue/add-passcodelock-switch
f1b5457 onFeaturedImageChanged signature changed: long instead of int
b7c9852 Merge branch 'hotfix/5.4.2' into release/5.5
1a4cd80 Merge commit '19320ef6206ed7104072d5a2f7fb7896c8e84596' into release/5.5
01d4f6b Use a long for featured image IDs
b3b5d0f Updating gradle plugin to 2.1.2
db7ff96 Merge branch 'hotfix/5.4.1' into release/5.5
8a9cc5e Merge commit '0e7e33bb330aea12fc3845d1c95b483845e63c6a' into hotfix/5.4.1
f8ad252 Merge pull request #4165 from wordpress-mobile/issue/4147-translated-original-size
fd891ba Merge commit 'e8a087f9fc25fa4e0dea63715bdd1a05e92f7db0' into hotfix/5.4.1
c98fb04 Merge branch 'hotfix/5.4.1' into issue/4147-translated-original-size
cb5a1c6 fix an issue with initial max width value in legacy image settings
a334c40 Update to latest utils version
82cc1b8 use MediaUtils.getImageWidthSettingFromString instead of referring to 'Original Size'
7840c5c Merge pull request #4161 from wordpress-mobile/issue/391editor-fix-legacy-image-settings
7f63f40 Merge commit '961a76c0bc931c3a484640f9fb1e3d6f7877857b' into hotfix/5.4.1
0a2287a associate the mediafile with newly created image span
d150911 Don't attempt to remove image selection formatting if the image is no longer attached to the document
55930ce On API 19 and below, don't set focus on the container when showing the edit overlay
50129ac When applying the edit image overlay, give focus to the edit container instead of the image
c70d784 Merge branch 'release/5.4' into release/5.5
7151f8e check for null parameters in createWPEditImageSpanRemote
0d59484 fix #4137: check if context and media file is null
c8b44ca Merge branch 'release/5.4' into develop
fd0cfb9 Merge commit '5da21eda6aa762a51acc7f29263ea5b6e42b3cd2' into release/5.4
5b0678c Merge branch 'release/5.4' into develop
b404d5b Block media button if action in progress
212dc2f fix editor tests
67eafc7 Don't allow publishing if insert image or insert video action in progress
707c603 fix wordpress-mobile/WordPress-Editor-Android#294: Block HTML mode until insert image or video has finished
7942521 Merge pull request #4121 from wordpress-mobile/issue/294editor-block-switch-to-html-mode-until-insert-image-finished
41adb14 Merge branch 'release/5.4' into develop
8f77d52 Block media button if action in progress
d35ddac bump minSdkVersion from 14 to 16
c026ad6 remove specific code for API < 16 in editor
25375d3 fix editor tests
10e48c6 Don't allow publishing if insert image or insert video action in progress
9499392 fix wordpress-mobile/WordPress-Editor-Android#294: Block HTML mode until insert image or video has finished
5f37dee chmod 644 image files
635b3fb Merge commit '3418d3e2da66bf5ecc19b5e073794c866711e776' into develop
53b29cc Merge pull request #3856 from wordpress-mobile/issue/3791-support-library-23.2
a981088 Updating to support library 23.4.0
2503fbd Merge branch 'develop' into issue/3791-support-library-23.2
f0bed16 Improved error message displayed when failing to load visual editor HTML
3ece15d Merge branch 'develop' into feature/magic-link
729d0cc Merge commit '3b37573c3bef0da83e7c0991c3ddd7069ea34947' into develop
0b8a733 Merge commit '4542685e8fcd0e490279dde87f9ac3d8887bc0af' into develop
f4ff5de Merge branch 'develop' into feature/magic-link
c099353 Merge pull request #4024 from wordpress-mobile/feature/update-gradle-plugin
46213c2 Merge commit '99075045579437eb0928d9fb5b363cf5d1774870' into develop
365c870 Updating gradle plugin to 2.1.0 for Android Studio 2.1.0
a2aa8be Merge branch 'develop' into feature/magic-link
9474d20 Merge commit 'ac1a4af3be8b6e95d1799ce2f82fca06a73577c0' into develop
d22e4c1 Merge branch 'develop' into feature/magic-link
bd19b42 Merge pull request #3967 from wordpress-mobile/issue/328editor-track-reflection-failure
b4be6f1 Merge pull request #3961 from wordpress-mobile/issue/3930-crash-when-adding-invalid-image
5f71918 Merge commit 'be4aac09995c4a35b2354854ef0f3ff5b1ae07e7' into develop
1da6d97 Use a static listener to handle reflection failures
9eca57e Merge branch 'develop' into feature/magic-link
d72224e Updates the p/div conversion regex to more strictly match tags
9cb2d66 Move the addMediaFile logic in an AsyncTask, only WPEditImageSpan construction now lives in a background thread
5221b23 Merge branch 'develop' into feature/magic-link
0c31d62 Merge commit 'c0f0848c74ef959fa90d150ae3cf93259c3fd08e' into develop
37fca47 Adding MissingPrefix ignore rule to Editor as well
fe21a2b Merge branch 'develop' into issue/3791-support-library-23.2
5b27ae2 Button is no longer screen width and extracting string resource
a41b87b Merge commit '52910dd0664cf2031a6a1c78f3cb1b170a4eeff9' into issue/editor-p-to-div-update
e640f54 Merge branch 'develop' into issue/editor-p-to-div-update
f645729 Merge pull request #3931 from wordpress-mobile/issue/fix-placeholder-title-in-french
6c7167d Merge commit 'd2f7ed4e05fa13e80fbe573f043fac43baf5e0b1' into issue/editor-p-to-div-update
ad999ba Updating to gradle 2.0
a5f0ab7 Updating support library to 23.3.0
f272c89 Updating to gradle 2.0
2f39640 Merge branch 'develop' into issue/3791-support-library-23.2
e15976b Updating to rc3
2543f5d Escape quotes on translated strings when calling execJavaScriptFromString
dc35a09 Merge commit 'c5b98a88c01551e8dbf44366072607d364ec01dd' into develop
5b33866 Updating build.gradle to latest rc3
8c52162 Merge branch 'develop' into issue/3791-support-library-23.2
eacf107 Merge pull request #3919 from wordpress-mobile/issue/update-build-tools
ef47ca9 Merge branch 'release/5.2' into release/5.3
096965f Updating the rest of the modules to buildToolsVersion 23.0.3
7255db3 Updating the rest of the modules to buildToolsVersion 23.0.3
9d0aa62 Merge branch 'develop' into issue/3791-support-library-23.2
738665c Merge commit '4c9324cf1eee00b66c76e0d5a917c86e1293a845' into develop
6ba1837 Add missing classes for images inserted from media library - also fix a bug with undefined alt text
82dc58c Add missing attributes for uploaded images
f752e83 update to android-gradle-2.0.0-rc1
7fe2fc9 upgrade to gradle plugin 2.0.0-beta7
921854c Merge commit 'c6efe0a9190244d40e64300efc9cca56ae5acd5c' into develop
e3b86d7 Merge branch 'develop' into issue/120editor-initial-focus
25c5d52 Merge commit '9b0b5fab24db9f435b278ad0b9e77d5895135700' into develop
722e4e3 Merge pull request #3897 from wordpress-mobile/issue/260editor-clear-failed-images-on-upload
ffe3c61 Null check getParentRangeOfFocusedNode/setRange in onMutationObserved - in case editor is not in focus
c3e0ae6 Show the software keyboard once the DOM has loaded
4834f1d Focus on the title field when opening posts
f4a78fb New EditorFragment method to removeAllFailedMediaUploads()
ae29ad5 New JS function ZSSEditor.removeAllFailedMediaUploads
1fa7a5d Merge pull request #3896 from wordpress-mobile/issue/300editor-broken-images-after-upload-2
9155094 remove debug logs
65838e8 Use remoteurl in the link wrapper
805af54 Converting all android:src to app:srcCompat to handle VectorDrawables
2b60eba Changing all Activity classes to AppCompatActivity to handle vector drawables
a5cace9 Merge branch 'develop' into issue/3791-support-library-23.2
80576a8 Merge branch 'develop' into issue/300editor-broken-images-after-upload-2
f3c2293 Merge branch 'develop' into issue/297editor-backspace-media
9593d8b Merge branch 'develop' into issue/3791-support-library-23.2
ac05d57 update to com.android.tools.build:gradle:2.0.0-beta7
369764a Updating support library to 23.2.1
b542c20 Merge branch 'develop' into issue/297editor-backspace-media
fa99288 Merge commit '8db246f15ce6f4d2c7f7f7ec51c68b87e9a66c2f' into develop
7bd6e58 Changed MutationObserver handling to check if the WebView supports it, rather than rely on API levels
96e1c24 Refactor: grouped mutation observation methods together
c603ab4 Refactored DOM element mutation listening, delegating everything to one trackNodeForMutation method
095cb82 Changed MutationObserver behavior to track individual media nodes instead of each contenteditable div
a0eba3d Moved failed media methods to the generic media method group
f93397d Parse for failed media when returning from HTML to visual mode
e956fc4 Track DOMNodeRemoved events when parsing for failed media
6e2c384 Fixed a variable name error in ZSSEditor.removeImage
ece9989 On API<19, use DOMNodeRemoved events to track media deletions (instead of the unsupported MutationObserver used for newer APIs)
7385103 Merge branch 'develop' into issue/297editor-backspace-media
5c92b29 Merge pull request #3804 from wordpress-mobile/issue/enable-editor-debug-mode
711b0ca Consume KEYCODE_VOLUME_UP event when debug print is called
abfd08e Merge commit 'a299686f47294c20ef04e818585f1d27cf069876' into develop
619e0ad broken retries
9323bbe Merge branch 'issue/enable-editor-debug-mode' into issue/300editor-broken-images-after-upload-2
dd0643f use a remoteUrl attribute to avoid seeing broken image if download failed
d4cf929 remove debug action bar button and log raw html when volume up button is pressed
4b6f10f fix function call errors
b9444d8 Add back image swapping onError
e9ae1aa Merge commit 'a03a1465ca3a5e6827a3a4c004b435b1bc0db4ee' into develop
2a884cf fix wordpress-mobile/WordPress-Editor-Android#300: Retry download onError after an upload
74c0aaf add missing comment
a03811b Updated gradle to 2.0.0-beta6
ea572e6 Fixes an issue where manually deleting uploading/failed media will cause the caret to disappear
b90e964 Notify native through a callback whenever uploading/failed media are manually deleted
77d406e catch a common JS exception
5df7cc7 Merge branch 'develop' into issue/288editor-log-js-errors-in-crashlytics
65a9f38 fix wordpress-mobile/WordPress-Editor-Android#288: new EditorWebViewAbstract.ErrorListener used to forward JS errors to Crashlytics
833c9eb Keep the format bar disabled on rotation when the title field is in focus
fc0d7dc Rely on ZSSEditor to flag uploads as completed in native-side checks
ef5c345 Added null checking for MediaType onMediaUploadFailed
548761e Wait until the ZSSEditor has replaced the local media with remote before marking it as completed
fdd35d2 Strip any trailing &nbsp; when returning the title
1669621 Merge commit '108ed89ccdc90830463e57ce4ff5ba64ef0acc8f' into feature/visual-editor
8169007 Editor 0.6 version bump
c3eb7a1 Updated localized string calls in ZSSEditor video methods
0394937 Merge branch 'feature/visual-editor' into feature/visual-editor-insert-video
0922237 Merge commit '87b5e7c0a01bceedcbad9abb9a2e71505bbfbf48' into feature/visual-editor
ad3a3d3 Escape quotes for URLs being passed to the JS editor
0557baa Use hasAttribute to null-check when parsing for failed media items
fb747c5 Wrapped called to getThumbnailURL in notNullStr() in the editor fragment
73c92bb Removed unnecessary console.logs
cbd283b Drop data-failed attribute from ZSSEditor.insertLocalVideo
26edba2 Merge branch 'feature/visual-editor' into feature/visual-editor-insert-video
4a14104 escape single quotes when calling execJavaScriptFromString
c0deade Use API<19 compatibility upload UI for video (imported from images)
90f682a Include videos in count of failed media uploads
cab0967 Mark uploading videos as failed when opening a post containing them, so they can be retried
4402006 Send VideoPress shortcode and poster URL to visual editor when video upload completes
6ba9482 Stop adding unnecessary 'data-wpid' attributed to completed video uploads
de44320 fix wordpress-mobile/WordPress-Editor-Android#285: markImage(Video)UploadFailed now called with 2 parameters
243ab51 Merge branch 'feature/visual-editor' into feature/visual-editor-insert-video
73ec713 Merge branch 'develop' into feature/visual-editor
6914fa4 Upgrade gradle plugin to 2.0.0-beta5
2df9685 Update gradle version in wrapper
4174b5d fix MockEditorActivity for tests
bae8be3 Merge commit '68c6f4cd95baefe3198dca9e8bd7d1ee3732f576' into issue/3610-media-tracking-fixes
a939bf1 Centralized tracking of added images/videos
093f551 Merge commit '097b51b9618f0fe23146c66b58918651e9c80bbc' into issue/3610-media-tracking-fixes
b3d04f7 Merge branch 'develop' into feature/visual-editor
09dad0a Merge pull request #3742 from wordpress-mobile/issue/update-to-android-gradle-plugin-2.0
ed5311f update to android gradle plugin beta4
f114c55 update to android gradle plugin 2.0.0-beta-2 - Instant Run
1a6e023 Updating to latest versions of internal dependencies
5ab9fda Keeping internal dependencies always pointing to the latest version
c8c18aa Merge commit 'c0c935fa4b3b6135be8099b637da57bede6b850f' into feature/visual-editor
906b9f4 Hide video fullscreen button
ee649cf Pause video playback when the WebView is no longer visible to the user
327b1e3 Use a blank placeholder src instead of videopress.mp4 to trigger videopress video loading
02b5dff Added some sanity checks for substring usage to JsCallbackReceiver
661aef5 Fixed a bug where videos would sometimes get deleted if they were the only thing in the post
865b3d0 Added support for video shortcodes on non-VideoPress sites
a895d60 Merge branch 'feature/visual-editor' into feature/editor-video-playback
7ac20f8 Added missing bracket in JS editor
0442aed Follow redirects when requesting thumbnails for the image settings dialog
ceb500b Always defer to super.shouldInterceptRequest in editor WebView unless an auth header is present
d82e4a9 Merge branch 'feature/visual-editor' into feature/editor-video-playback
4beed68 When looking up a VideoPress ID in the DB fails, refresh the blog media and check again
35fed76 Remove the onError attribute from VideoPress videos if an empty video url is returned
4af2960 Added the ability to tap a placeholder VideoPress video to attempt to load it
5c43e8d Don't use the placeholder poster image for videopress videos
3cda722 Add space after videos when converting from VideoPress shortcode
f4c2e85 Only apply custom headers for network URL resource requests
3b94949 Implement new EditorFragmentListener method in mock activity for integration tests
49e014f Convert VideoPress shortcodes to video elements and back in the visual editor
749403b Imported ZSSRichTextEditor video methods and callback methods from iOS
d411273 Imported video CSS from iOS
fe99f03 Added missing method implementation to test mock activity
668c4f6 Retrieve an auth header if necessary when launching the image settings dialog
dbc0418 Use the safeToAddWordPressComAuthHeader utility method for resource requests in the new editor's WebView
41dcd76 Updated the utils artifact version for the editor
b616eb3 Moved setupUrlConnection() to the utils library
162e8e6 Renamed EditorFragment's setWebViewHeader to setCustomHttpHeader
82c14c2 Use custom headers for image settings dialog image requests
cc018e2 Extracted some duplicated HttpURLConnection building code into a utility method
3689291 When an Authorization HTTP header is detected, force using the HTTPS protocol in the WebViewClient
9d7cb78 Added support for custom headers to the editor's WebView, set through the EditorFragmentAbstract
caedd9b Editor 0.5 version bump
979e397 Added full support for gallery types
b8f0c81 Added a fix enabling galleries to be added to the editor before the DOM loads
ce73ca2 Fixed creating a new post by making a gallery from the Media Library (the gallery wasn't being added to the new post)
84b7c81 Merge branch 'feature/visual-editor' into feature/editor-galleries
4874732 Merge branch 'feature/visual-editor' into feature/editor-sync-0.5
7a2a9d8 Merge branch 'develop' into feature/visual-editor
73dbba9 Merge branch 'develop' into feature/editor-sync-0.5
5ad3103 Merge commit '2467f23341a72e17460995133a375e63252e88b3' into feature/sync-editor-lib
8afa221 Added support for creating galleries from local images, using a placeholder shortcode while uploading
fd5141c Extracted duplicate paragraph-wrapping code into a separate method in the ZSS editor
04986d6 Added support for inserting galleries using media library images
409b5d9 Merge branch 'feature/visual-editor' into feature/editor-featured-images
e90a474 Merge branch 'develop' into feature/visual-editor
fe047ba Removed unused 'Include image in post content' checkbox from image settings
2577013 Updating gradle plugin to 1.5.0 and support/build tools to latest for sub projects
ee69781 Use a callback instead of a getter to notify the host activity when the featured image changes
17695af Add the remote media id to image tags when inserting from media gallery
e3cdc3c Hide the featured image checkbox if feature images aren't supported
6e410c9 Updated Editor example project with changes to onMediaUploadProgress
5f7cbc3 Fixed a crash issue in the image settings dialog fragment
6ac416c Converted featured id handling methods to be part of EditorFragmentAbstract
4a9d2dc Added support for getting and setting the featured image id to the editor fragments
c1cb3fb Don't clear all class data in ZSSEditor.markImageUploadDone
8ec7e95 Add the remote image ID to the image tag when an image upload completes
eff15be Added support for setting/unsetting an image as featured to the image settings dialog
607feca Modified onMediaTapped to pass the image meta data as a JSONObject
b4cf8ca Fixed a broken test and an issue with the editor demo activity
aa69c47 Implemented missing method in EditorFragmentAbstractTest
bada788 Added some empty string checking when retrieving failed media ids from the ZSSEditor
ab9c7a0 Adjusted the pattern used by the ZSSEditor to find images that are uploading
931052b Disable editor format bar buttons when post/page contains failed uploads
33b6921 Updated EditorFragment to handle exiting the editor with media uploads in progress more gracefully
80c282e Added a 'delete' flag to onMediaUploadCancelClicked
8759b61 Fixed a bug where the media upload progress bar wouldn't display due to a localization issue
8078247 Visual editor lib version bump
4675c84 Updated image settings dialog to always clear the custom ActionBar view
04cabe7 Merge commit '7b6a9d464896683ba4aef6f4dccc9021641e5d71' into develop
4620b05 Updating build tools to 23.0.1
f2fcbf3 Merge branch 'release/4.4' into develop
1365ff9 use default AppCompat theme on EditLink and AddCategory dialog
365d32c set targetSdkVersion to 23 and clean up lib dependencies
d7f3655 migrate from mavenCentral to jcenter (which is now the default for Android Studio)
49cb22c upgrade subtrees to latest android tools
9faf049 update to gradle plugin 1.3.1 and gradle 2.6
a236689 Merge branch 'develop' into feature/update-to-gradle-2.4
72f97b9 upgrade to gradle 2.5 and gradle plugin 1.3.0
f7c4ca3 Merge branch 'develop' into feature/update-to-gradle-2.4
ce1cb7f Merge branch 'develop' into feature/update-to-gradle-2.4
61dd677 Merge commit '33111c4b44646d8be75a874bbea053d1fb046f98' into merge-visual-editor
2538253 Merge commit 'f9336b16d6ee89fdb83f26786ceecbcd6147b5fa' into merge-visual-editor
9896ee0 Merge commit '5f30f5370258c76caec14054688312c66aadd7cf' into develop
9f79a47 Merge commit '56693c52342639687b09982e69b92b0f9f988475' into develop
caba147 Merge commit 'df5f63473447582437fa7019684080b1ae47a39d' into feature/editor-activity-fixes
c55ea47 Merge commit '9eaf95842954e90dbb01618e932ce1560ba1f5f6' into update-editor-library
406f150 Updated support library and build tools
01000cd update to gradle android plugin 1.2.3
04e62d3 update support lib to 22
67eef376 update to android-gradle plugin 1.1.3 and build tools 22.0.1
d5790ec move addPictureButton action to LegacyEditorFragment
1ae344a Merge pull request #2637 from wordpress-mobile/issue/2635-npe-legacyeditor-onactivityresult
51bf367 fix #2635: check if data is null
56d93ce Merge commit '40e798bf739c94adbc7aa9156ded0a5ad28dc462' into develop
2ad75f2 update to wputils 1.6.0
d8ee144 Update wpeditor
5249318 Use a placeholder image when thumbnail can't be decoded
ba1df21 Removing potential race condition with WP image loading threads.
9092121 WP library images and local images working.
2a80bbc Local images are maintained after fragment is re-created.
0b6a5b8 Returning to the post editor won't crash if Activity was destroyed.
fc367ba Fix #2406 - Load media file in the background
808427c fix gallery placeholder icon
2a3fba5 Tapping a media gallery span opens gallery editor.
2f20e48 Adding missing override annotation.
a41c33e Using isVideo to determine if a file is a video.
e9100ea enable gallery handling
cf70efb remove unused code
ee91f79 first step at introducing the new media picker
e80442d rename and update editor colors
adc2819 Merge branch 'develop' into feature/modularize-editor
468129f fix local draft style saving by introducing an awful "getSpannedContent()" method :(
a18e293 EditLinkActivity is now independent from the EditPostActivity
9982612 add local draft / remote post example
bec8371 make the legacy editor works in the example project
87257aa LegacyEditorFragment now lives in the editor subproject
4c18e6a split MediaUtils in MediaUtils and WordPressMediaUtils - remove references to WordPress.java in MediaUtils
9909907 move WPUnderlineSpan.java and MediaGalleryImageSpan.java to WPUtils
eaa41f0 use setFeaturedImageSupported instead of using WordPress.getCurrentBlog().isFeaturedImageCapable()
3fc876b appendMediaFile now able to load local media
a299756 reenable appendMedia in LegacyEditorFragment
f6df495 split methods to be usable on MediaFile instead of WPImageSpan
e3e82b1 move WPEditImageSpan bitmap loading to the constructor
a7d7750 move WPImageSpan and MediaFile to WPUtils - also create a WPEditImageSpan class
74f33a8 first step to remove getContentEditText/getTitleEditText

git-subtree-dir: libs/editor
git-subtree-split: 793211609b7e2d63d416ac1ec0a4bacc26f5309f
  • Loading branch information
maxme committed Aug 26, 2016
1 parent 8c64473 commit 8730fb5
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android:
- extra-android-support
- platform-tools
- tools
- build-tools-24.0.0
- build-tools-24.0.2
- android-24

env:
Expand Down
12 changes: 6 additions & 6 deletions WordPressEditor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.1.3'
}
}

Expand All @@ -19,7 +19,7 @@ android {
publishNonDefault true

compileSdkVersion 24
buildToolsVersion "24.0.0"
buildToolsVersion "24.0.2"

defaultConfig {
versionCode 13
Expand All @@ -45,10 +45,10 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'org.wordpress:utils:1.10.0'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'org.wordpress:utils:1.11.0'

// Test libraries
testCompile 'junit:junit:4.11'
Expand Down
27 changes: 27 additions & 0 deletions WordPressEditor/src/main/assets/ZSSRichTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ ZSSEditor.getField = function(fieldId) {
return field;
};

ZSSEditor.moveCaretToCoords = function(x, y) {
if (document.caretRangeFromPoint) {
var range = document.caretRangeFromPoint(x, y);

var selection = window.getSelection();

if (range && selection.rangeCount) {
selection.removeAllRanges();
selection.addRange(range);
}
}
};

ZSSEditor.getFocusedField = function() {
var currentField = $(this.findParentContenteditableDiv());
var currentFieldId;
Expand Down Expand Up @@ -2464,6 +2477,20 @@ ZSSEditor.insertHTML = function(html) {
this.sendEnabledStyles();
};

ZSSEditor.insertText = function(text, reformatVisually) {
var focusedField = ZSSEditor.getFocusedField();
if (focusedField.isMultiline() && focusedField.getHTML().length == 0) {
// when the text field is empty, we need to add an initial paragraph tag
text = Util.wrapHTMLInTag(text, ZSSEditor.defaultParagraphSeparator);
}

if (reformatVisually) {
text = wp.loadText(text);
}

ZSSEditor.insertHTML(text);
};

ZSSEditor.isCommandEnabled = function(commandName) {
return document.queryCommandState(commandName);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.wordpress.android.editor;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.ClipData;
import android.content.ClipDescription;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
Expand All @@ -12,13 +16,15 @@
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.os.SystemClock;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.DragEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
Expand All @@ -36,6 +42,7 @@
import org.wordpress.android.editor.EditorWebViewAbstract.ErrorListener;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.DisplayUtils;
import org.wordpress.android.util.JSONUtils;
import org.wordpress.android.util.ProfilingUtils;
import org.wordpress.android.util.ShortcodeUtils;
Expand All @@ -46,9 +53,11 @@
import org.wordpress.android.util.helpers.MediaGallery;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
Expand All @@ -72,6 +81,11 @@ public class EditorFragment extends EditorFragmentAbstract implements View.OnCli

private static final float TOOLBAR_ALPHA_ENABLED = 1;
private static final float TOOLBAR_ALPHA_DISABLED = 0.5f;

private static final List<String> DRAGNDROP_SUPPORTED_MIMETYPES_TEXT = Arrays.asList(ClipDescription.MIMETYPE_TEXT_PLAIN,
ClipDescription.MIMETYPE_TEXT_HTML);
private static final List<String> DRAGNDROP_SUPPORTED_MIMETYPES_IMAGE = Arrays.asList("image/jpeg", "image/png");

public static final int MAX_ACTION_TIME_MS = 2000;

private String mTitle = "";
Expand All @@ -85,6 +99,8 @@ public class EditorFragment extends EditorFragmentAbstract implements View.OnCli
private int mSelectionStart;
private int mSelectionEnd;

private String mFocusedFieldId;

private String mTitlePlaceholder = "";
private String mContentPlaceholder = "";

Expand All @@ -110,6 +126,130 @@ public class EditorFragment extends EditorFragmentAbstract implements View.OnCli

private long mActionStartedAt = -1;

private final View.OnDragListener mOnDragListener = new View.OnDragListener() {
private long lastSetCoordsTimestamp;

private boolean isSupported(ClipDescription clipDescription, List<String> mimeTypesToCheck) {
if (clipDescription == null) {
return false;
}

for (String supportedMimeType : mimeTypesToCheck) {
if (clipDescription.hasMimeType(supportedMimeType)) {
return true;
}
}

return false;
}

@Override
public boolean onDrag(View view, DragEvent dragEvent) {
switch (dragEvent.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
return isSupported(dragEvent.getClipDescription(), DRAGNDROP_SUPPORTED_MIMETYPES_TEXT) ||
isSupported(dragEvent.getClipDescription(), DRAGNDROP_SUPPORTED_MIMETYPES_IMAGE);
case DragEvent.ACTION_DRAG_ENTERED:
// would be nice to start marking the place the item will drop
break;
case DragEvent.ACTION_DRAG_LOCATION:
int x = DisplayUtils.pxToDp(getActivity(), (int) dragEvent.getX());
int y = DisplayUtils.pxToDp(getActivity(), (int) dragEvent.getY());

// don't call into JS too often
long currentTimestamp = SystemClock.uptimeMillis();
if ((currentTimestamp - lastSetCoordsTimestamp) > 150) {
lastSetCoordsTimestamp = currentTimestamp;

mWebView.execJavaScriptFromString("ZSSEditor.moveCaretToCoords(" + x + ", " + y + ");");
}
break;
case DragEvent.ACTION_DRAG_EXITED:
// clear any drop marking maybe
break;
case DragEvent.ACTION_DROP:
if (mSourceView.getVisibility() == View.VISIBLE) {
if (isSupported(dragEvent.getClipDescription(), DRAGNDROP_SUPPORTED_MIMETYPES_IMAGE)) {
// don't allow dropping images into the HTML source
ToastUtils.showToast(getActivity(), R.string.editor_dropped_html_images_not_allowed,
ToastUtils.Duration.LONG);
return true;
} else {
// let the system handle the text drop
return false;
}
}

if (isSupported(dragEvent.getClipDescription(), DRAGNDROP_SUPPORTED_MIMETYPES_IMAGE) &&
("zss_field_title".equals(mFocusedFieldId))) {
// don't allow dropping images into the title field
ToastUtils.showToast(getActivity(), R.string.editor_dropped_title_images_not_allowed,
ToastUtils.Duration.LONG);
return true;
}

if (isAdded()) {
mEditorDragAndDropListener.onRequestDragAndDropPermissions(dragEvent);
}

ClipDescription clipDescription = dragEvent.getClipDescription();
if (clipDescription.getMimeTypeCount() < 1) {
break;
}

ContentResolver contentResolver = getActivity().getContentResolver();
ArrayList<Uri> uris = new ArrayList<>();
boolean unsupportedDropsFound = false;

for (int i = 0; i < dragEvent.getClipData().getItemCount(); i++) {
ClipData.Item item = dragEvent.getClipData().getItemAt(i);
Uri uri = item.getUri();

final String uriType = uri != null ? contentResolver.getType(uri) : null;
if (uriType != null && DRAGNDROP_SUPPORTED_MIMETYPES_IMAGE.contains(uriType)) {
uris.add(uri);
continue;
} else if (item.getText() != null) {
insertTextToEditor(item.getText().toString());
continue;
} else if (item.getHtmlText() != null) {
insertTextToEditor(item.getHtmlText());
continue;
}

// any other drop types are not supported, including web URLs. We cannot proactively
// determine their mime type for filtering
unsupportedDropsFound = true;
}

if (unsupportedDropsFound) {
ToastUtils.showToast(getActivity(), R.string.editor_dropped_unsupported_files, ToastUtils
.Duration.LONG);
}

if (uris.size() > 0) {
mEditorDragAndDropListener.onMediaDropped(uris);
}

break;
case DragEvent.ACTION_DRAG_ENDED:
// clear any drop marking maybe
default:
break;
}
return true;
}

private void insertTextToEditor(String text) {
if (text != null) {
mWebView.execJavaScriptFromString("ZSSEditor.insertText('" + Utils.escapeHtml(text) + "', true);");
} else {
ToastUtils.showToast(getActivity(), R.string.editor_dropped_text_error, ToastUtils.Duration.SHORT);
AppLog.d(T.EDITOR, "Dropped text was null!");
}
}
};

public static EditorFragment newInstance(String title, String content) {
EditorFragment fragment = new EditorFragment();
Bundle args = new Bundle();
Expand Down Expand Up @@ -163,6 +303,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mWebView.setOnImeBackListener(this);
mWebView.setAuthHeaderRequestListener(this);

mWebView.setOnDragListener(mOnDragListener);

if (mCustomHttpHeaders != null && mCustomHttpHeaders.size() > 0) {
for (Map.Entry<String, String> entry : mCustomHttpHeaders.entrySet()) {
mWebView.setCustomHeader(entry.getKey(), entry.getValue());
Expand Down Expand Up @@ -218,6 +360,10 @@ public void onFocusChange(View v, boolean hasFocus) {
mSourceViewTitle.setHint(mTitlePlaceholder);
mSourceViewContent.setHint("<p>" + mContentPlaceholder + "</p>");

// attach drag-and-drop handler
mSourceViewTitle.setOnDragListener(mOnDragListener);
mSourceViewContent.setOnDragListener(mOnDragListener);

// -- Format bar configuration

setupFormatBarButtonMap(view);
Expand Down Expand Up @@ -247,6 +393,17 @@ public void onResume() {
}
}

@Override
public void onAttach(Activity activity) {
super.onAttach(activity);

try {
mEditorDragAndDropListener = (EditorDragAndDropListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + " must implement EditorDragAndDropListener");
}
}

@Override
public void onDetach() {
// Soft cancel (delete flag off) all media uploads currently in progress
Expand Down Expand Up @@ -1127,12 +1284,12 @@ public void run() {
}

public void onSelectionChanged(final Map<String, String> selectionArgs) {
final String focusedFieldId = selectionArgs.get("id"); // The field now in focus
mFocusedFieldId = selectionArgs.get("id"); // The field now in focus
mWebView.post(new Runnable() {
@Override
public void run() {
if (!focusedFieldId.isEmpty()) {
switch (focusedFieldId) {
if (!mFocusedFieldId.isEmpty()) {
switch (mFocusedFieldId) {
case "zss_field_title":
updateFormatBarEnabledState(false);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import android.app.Activity;
import android.app.Fragment;
import android.net.Uri;
import android.os.Bundle;
import android.text.Spanned;
import android.view.DragEvent;

import com.android.volley.toolbox.ImageLoader;

import org.wordpress.android.util.helpers.MediaFile;
import org.wordpress.android.util.helpers.MediaGallery;

import java.util.ArrayList;
import java.util.HashMap;

public abstract class EditorFragmentAbstract extends Fragment {
Expand Down Expand Up @@ -49,6 +52,7 @@ public static MediaType fromString(String value) {
private static final String FEATURED_IMAGE_WIDTH_KEY = "featured-image-width";

protected EditorFragmentListener mEditorFragmentListener;
protected EditorDragAndDropListener mEditorDragAndDropListener;
protected boolean mFeaturedImageSupported;
protected long mFeaturedImageId;
protected String mBlogSettingMaxImageWidth;
Expand Down Expand Up @@ -150,6 +154,14 @@ public interface EditorFragmentListener {
void onTrackableEvent(TrackableEvent event);
}

/**
* Callbacks for drag and drop support
*/
public interface EditorDragAndDropListener {
void onMediaDropped(ArrayList<Uri> mediaUri);
void onRequestDragAndDropPermissions(DragEvent dragEvent);
}

public enum TrackableEvent {
HTML_BUTTON_TAPPED,
UNLINK_BUTTON_TAPPED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.show();
Expand Down
5 changes: 5 additions & 0 deletions WordPressEditor/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@
<string name="editor_failed_uploads_switch_html">Some media uploads have failed. You can\'t switch to HTML mode
in this state. Remove all failed uploads and continue?</string>
<string name="editor_remove_failed_uploads">Remove failed uploads</string>

<string name="editor_dropped_text_error">Error occurred while dropping text</string>
<string name="editor_dropped_title_images_not_allowed">Dropping images in the Title is not allowed</string>
<string name="editor_dropped_html_images_not_allowed">Dropping images while in HTML mode is not allowed</string>
<string name="editor_dropped_unsupported_files">Warning: not all dropped items are supported!</string>
</resources>

0 comments on commit 8730fb5

Please sign in to comment.