Skip to content

Conversation

yuvalgnessin-qz
Copy link
Contributor

This PR is meant to replace #911 since @felipevaladares was no longer available to complete the requested changes.

This branch is forked from his and addresses all remaining comments from @cameronvoell from that PR, including fixing the bug that keeps the background button highlighted.

All changes since #911 are implemented by @lvcasasanta

Feature

  • Added CssBackgroundColorPlugin based on CssUnderlinePlugin
  • Added AztecBackgroundColorSpan
  • General changes to implement and use BackgroundColorSpan

Test

  1. Run the app
  2. Select some text
  3. Click on the new button that is located between Bold and Quote

Review

@cameronvoell

device-2020-05-26-184604

felipevaladares and others added 23 commits May 26, 2020 02:10
- Added CssBackgroundColorPlugin based on CssUnderlinePlugin
- Added AztecBackgroundColorSpan
- General changes to implement and use BackgroundColorSpan
…acilitate the use on recyclerview with multiple edittext for example
Just standardizing the background color.
This condition will not mark background spans with different colors.
It means background with different specified color will not have the background button highlighted.
@yuvalgnessin-qz
Copy link
Contributor Author

@jd-alexander since you seem to be the most active maintainer currently on this project, do you think you might be able to look at this pull request as well?

I'm also hoping you could help me fix the issue with Connected Tests on CI. The output is:

*** WARNING : deprecated key derivation used.
Using -iter or -pbkdf2 would be better.
bad decrypt
140156466037888:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:../crypto/evp/evp_enc.c:570:

Exited with code exit status 1
CircleCI received exit code 1

@mchowning
Copy link
Contributor

Since you reviewed the previous PR, could you take a look at this one as well @cameronvoell ?

@cameronvoell cameronvoell self-requested a review January 27, 2021 18:34
@yuvalgnessin-qz
Copy link
Contributor Author

Thanks for taking a look @cameronvoell and @mchowning! Any ETA on when this might be reviewed?

@cameronvoell
Copy link
Contributor

@yuvalgnessin-qz Thanks for your patience. I have this in my queue and should be able to get to it before the end of this week, and hopefully earlier. Looking forward to reviewing the updates. 🙇

@yuvalgnessin-qz
Copy link
Contributor Author

Hi again @cameronvoell - do you still think you might be able to get to this today, or will it have to wait until next week?

No worries either way; I'm sure you're very busy!

override val textFormats: Set<ITextFormat> = setOf())
: IToolbarAction {

BACKGROUND(
Copy link
Contributor

@cameronvoell cameronvoell Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yuvalgnessin-qz @lvcasasanta, see point 3 in this comment: #911 (review). With the new background button, I think it makes sense to have it be easy for each project using Aztec to enable or disable the background button based off whether it is added as a plugin. @felipevaladares addressed this concern with this commit in the previous PR a95d50e, but you are reversing that by re-adding the background button to the default Toolbar section here.

I see this change was part of your commit for fixing the button active state issue. Can you fix that issue while maintaining our ability to not add the background button if the plugin is not added to our aztec instance? For reference you can check out the behavior of the Page and More buttons. If you comment out the lines where they are added, they no longer appear in the toolbar.

.addPlugin(MoreToolbarButton(visualEditor))

Let me know if that makes sense. Thanks!

@cameronvoell
Copy link
Contributor

Hi again @cameronvoell - do you still think you might be able to get to this today, or will it have to wait until next

Hi @yuvalgnessin-qz See my comment here: #934 (comment)

My testing looked good for the other concerns so far, there is just that one issue in that comment above that needs to be addressed. I'll test some more this week to see if there are any other concerns.

@yuvalgnessin-qz
Copy link
Contributor Author

Thanks for the feedback @cameronvoell! I'll try to find time to address your concern today.

FWIW, as of last week we have already shipped an app to production that uses the code in this branch, and so far it seems stable!

@yuvalgnessin-qz
Copy link
Contributor Author

@cameronvoell I just pushed a commit with the changes you requested. Now, the background color will not appear unless it is added as a plugin.

In order to make this work, I had to modify the logic in AztecToolbar.addButton(). This must be the first time that a toolbar action has been added as a plugin, because it didn't work out of the box. Luckily, the tests I had written in 4261e37 caught these bugs as soon as they were introduced.

Check out the last commit (ab286ed) for the changes in question. Hopefully now we are close to getting this merged!

@yuvalgnessin-qz
Copy link
Contributor Author

Hi again @cameronvoell! Any updates?

@yuvalgnessin-qz
Copy link
Contributor Author

Hello again @cameronvoell! Do you think there's any chance of having this merged upstream at some point? Or are you and your team too busy right now? If so, I can close the PR - let me know.

@cameronvoell
Copy link
Contributor

Hi @yuvalgnessin-qz Sorry I was MIA for a bit. The changes you made look good. Unfortunately I'm seeing some failing end to end or "connected" tests. CircleCI is failing on this PR because it's coming from a fork, so that's fine, but you can see on this other branch I made that when connected tests are run here, we are seeing some failures: https://app.circleci.com/pipelines/github/wordpress-mobile/AztecEditor-Android/464/workflows/69fa00ae-551c-4e6d-9b06-1043f15945dc/jobs/1329

You can run those tests locally using ./gradlew cAT in the root folder AztecEditor-Android. More details here: https://github.com/wordpress-mobile/AztecEditor-Android#before-running-instrumentation-tests

As far as I can tell the failing tests are all crashing at this line here:

val view = findViewById<ToggleButton>(action.buttonId)
if (view.isChecked) actions.add(action)
I'll dig around a bit to see why thats occurring in the test, to see if it's catching something that can occur in regular usage, or if it's caused by the conditions of the test.

Apologize for the gap in the reviews, I can check more regularly moving forward on this.

val isToolbarAction = ToolbarAction.values().contains(buttonPlugin.action)
button.setOnClickListener {
if (isToolbarAction) {
onToolbarAction(buttonPlugin.action)
Copy link
Contributor Author

@yuvalgnessin-qz yuvalgnessin-qz Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cameronvoell , thanks for taking another look! Based on the stacktrace it looks like the errors are coming from this change right here. Before these changes, I believe onToolbarAction would never have been called from a button click listener. Nevermind, I see that line 427 has button?.setOnClickListener { onToolbarAction(toolbarAction) }

I will try to find time to look into this deeper today. It's been a while since I was originally working on this and have since moved on to other projects, so I'm not sure how much time I'll be able to dedicate to it now. But I'll do my best

action != ToolbarAction.ELLIPSIS_EXPAND) {
val view = findViewById<ToggleButton>(action.buttonId)
if (view.isChecked) actions.add(action)
if (view?.isChecked == true) actions.add(action)
Copy link
Contributor Author

@yuvalgnessin-qz yuvalgnessin-qz Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cameronvoell, this change should fix the IllegalStateException failures on CI. At first I debated whether this was the right solution, but I think it makes sense. Before this change, we were guaranteed that all toolbar actions were always present. But now that background color is an optional plugin, for the first time ever it's possible that one of the actions in ToolbarAction.values() is not present.

An alternative way to fix these tests would've been to move the following out of the if (!isRunningTest) branch:

            aztec.addPlugin(CssBackgroundColorPlugin())
            aztec.addPlugin(BackgroundColorButton(visualEditor))

TBH I'm not exactly sure why we chose to put that inside if (!isRunningTest) in the first place, but I felt that this was a better solution overall to prevent crashes from users of the library that don't add the plugin.

Unfortunately this change alone does not resolve all of the espresso tests though. Some tests were fully fixed by this, but some of them are now failing for different reasons. One such example is FormattingHistoryTests.testAddBoldUndoRedo(), which now fails like this:

Expected: EditText matches <strong>Testing</strong>
     Got: "SourceViewEditText{ ... text=<strong><b>T</b></strong><b>esting</b> ... }"

I have no idea why the changes in this PR would cause the <b> tags to be added, or why they'd be cutting of the "T" in "Testing". It may be due to changes that occurred before I got involved. As someone with more context on this project, do you have any ideas what might be causing this?

Thanks very much!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look.

@imthiaz
Copy link

imthiaz commented Apr 7, 2021

@yuvalgnessin-qz Could you please share your source code gradle link so that i can locally execute the color span functionality with my application. i have been using the aztec toolbar in my application.

@yuvalgnessin-qz
Copy link
Contributor Author

yuvalgnessin-qz commented Apr 7, 2021

@imthiaz you can view our fork and its releases here and here, and use jitpack to package it through github the same way you would the wordpress artifact.

Something like this:

repositories {
    maven { url 'https://jitpack.io' } // For projects hosted on github
}

dependencies {
    implementation("com.github.quizlet:AztecEditor-Android:background-color-support-v2.1")
}

You are free to use it, but I cannot make any guarantees regarding how long we will be maintaining this fork and whether we will be updating it from the upstream project, nor can I make any guarantees regarding what versioning scheme we may use if we do make changes in the future. For now, it is not in active development. The best long-term approach for maintainability would be for Wordpress to merge this PR upstream so that we can both depend on the original dependency, rather than on the fork.

@imthiaz
Copy link

imthiaz commented Apr 8, 2021 via email

@yuvalgnessin-qz
Copy link
Contributor Author

@imthiaz you can set the background color to whatever you want using AztecText.setBackgroundSpanColor()

@imthiaz
Copy link

imthiaz commented Apr 9, 2021

@imthiaz you can set the background color to whatever you want using AztecText.setBackgroundSpanColor()

Ok thanks for the update.

@yuvalgnessin-qz Do we also support font color change from your version of aztec, as i could see in the above mentioned first AztecDEMO screenshot some text in green color - i.e Italic (Red), Underline (Green with underline.)

Can you let me know how to input such green colored words using aztec if possible.

Initially i asssumed aztec android version does not support font color options

@yuvalgnessin-qz
Copy link
Contributor Author

@imthiaz I am not sure if Aztec supports text color changing, because that's not something I use it for. It looks like the underline text you asked about in the demo is hardcoded with HTML like this: "<u style=\"color:lime\">Underline</u><br>". You can see that here. I don't know if Aztec supports changing it via toolbar.

This pull request is for background color support only. I am not a maintainer of this library and have no intention of adding any other features to it at this time. If you have any questions that are not related to background color, please open an Issue on the github project. And if there are any missing features that you'd like to add, feel free to open a pull request!

@imthiaz
Copy link

imthiaz commented Apr 12, 2021 via email

@yuvalgnessin-qz
Copy link
Contributor Author

yuvalgnessin-qz commented Jan 20, 2023

Hello @oguzkocer @fluiddot @planarvoid @khaykov !

I understand that between the time this PR was opened and approximately October 2021, this project was inconsistently maintained. However, I'm happy to see that for the past year or so there have been regular releases.

If I update this branch against trunk, would you all consider merging it upstream, and if necessary, help me get it over the finish line?

Thank you!

@oguzkocer
Copy link
Contributor

Hi there @yuvalgnessin-qz 👋 I am sorry about the late reply. I was on an extended leave at the time of your ping.

I brought this up internally and @SiobhyB graciously volunteered with the review process. I think she is planning to leave a reply as well.

@yuvalgnessin-qz
Copy link
Contributor Author

@oguzkocer thanks for the reply, and welcome back. I did in fact update my fork from trunk back in January when I wrote the comment, but the changes are in another branch. I would be happy to either update this branch with those changes or open a new PR from the updated branch.

@SiobhyB if I do that, will you be able to help with next steps to get this merged upstream? Thanks!

@SiobhyB
Copy link

SiobhyB commented Apr 3, 2023

👋 @yuvalgnessin-qz, thanks for your persistence and patience with these changes!

I'd be happy to work towards getting this merged with you. Merging the latest changes from trunk would be a welcome starting point before I'm able to finish catching up on all the discussions so far. 🙇‍♀️

@yuvalgnessin-qz
Copy link
Contributor Author

@SiobhyB sounds good. I'll let you know when that's done, then hand it off to you. Thanks!

@yuvalgnessin-qz
Copy link
Contributor Author

yuvalgnessin-qz commented Apr 4, 2023

Hi @SiobhyB, I decided to open a fresh PR off of a new branch. Here it is: #1041

@SiobhyB
Copy link

SiobhyB commented Apr 4, 2023

@yuvalgnessin-qz, thank you! I'll go ahead to close this one.

@SiobhyB SiobhyB closed this Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants