wordpress-mobile / WordPress-Android

WordPress for Android
http://android.wordpress.org
GNU General Public License v2.0
2.99k stars 1.32k forks source link

Issue/21137 Align both buttons to the left #21327

Closed Agoni-0 closed 1 month ago

Agoni-0 commented 1 month ago

Fixes #


Descrpition:

The related issue is https://github.com/wordpress-mobile/WordPress-Android/issues/21137#issue-2479746837. This issuse is about the cluttered interface cased by button THE VERSION FROM ANOTHER DEVICE being divided into two lines.

It can be seen that button THE VERSION FROM THIS APP is aligned to the right, while button THE VERSION FROM ANOTHER DEVICE is centered. And the author of this issue suggests that Align both buttons to the left to maximize the available space and ensure that each button occupies a single line. So I just follow his suggestion and solve this issue.

After reading the code, I found out it was the problem of MaterialAlertDialogBuilder. It uses the default style, which aligns the positive, negative and cancel button to the right and the text of them to the center. It works nice while buttons are in the same line. If they need more than one line, they will cause a cluttered interface.

So, I just create a style to solve this issue.

Problems:

When using Jurassic.Ninja test site to test the codes, I'm unable to reproduce a post with You've made unsaved changes to this poststatus, which can lead to a page shown in the picture above.

However, I can do this using an account. Here are my steps:

  1. Open WordPress instead of Jetpack to publish a post.
  2. Open Jetpack to change the same post without update.
  3. Open WordPress , and the post will have You've made unsaved changes to this poststatus.

    If there are any problems, please tell me.

Solution:

I found that I can make a Version conflict post, which can lead to a page the same as the post mentioned above. Here are my steps.

  1. Open WordPress Pre-Alpha and publish a post. Change the post without update.
  2. Open Jetpack, change the same post and update.
  3. Open WordPress Pre-Alpha, and the post will have Version conflict.
    So, I test my codes with this kind of post.

To Test:

1.When a button is divided into two lines , the interface meets the requirements.

4.When two buttons are in the same line, the interface retains the original style.

5.When in dark mode


Regression Notes

  1. Potential unintended areas of impact

    The style of MaterialAlertDialogBuilder depends on parent activity or fragment when not asigned to a specific style. However, to solve the issue, I have to change the style of three buttons. I set their parent style to Widget.MaterialComponents.Button.TextButton and changed two properties android:layout_gravity and android:gravity. This may have an impact under different parent styles of activity or fragment.

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    I search all the codes which use this dialog. And all of them works well.

  3. What automated tests I added (or what prevented me from doing so)

    None.


PR Submission Checklist:


Testing Checklist (strike-out the not-applying and unnecessary ones):

nbradbury commented 1 month ago

@Agoni-0 Thanks, this is a nice solution! But while we're fixing this I wonder we should simplify the wording? We could move the line "Choose a version to load" to appear above the two buttons, and change the button wording to just "From this app" and "From another device".

Agoni-0 commented 1 month ago

@Agoni-0 Thanks, this is a nice solution! But while we're fixing this I wonder we should simplify the wording? We could move the line "Choose a version to load" to appear above the two buttons, and change the button wording to just "From this app" and "From another device".

It's a good advice. But I think this change is necessary. Perhaps a short sentence in English can become very long when translated into other languages. Should I simplify the words?

nbradbury commented 1 month ago

Should I simplify the words?

I think we should, yes. But I'm not suggesting dropping your style - we should keep that, because as you point out, the wording could be longer in languages other than English.

Agoni-0 commented 1 month ago

I think we should, yes.

So the next step I need to do is to change the button wording to just "From this app" and "From another device", including in other languages?

nbradbury commented 1 month ago

So the next step I need to do is to change the button wording to just "From this app" and "From another device", including in other languages?

Sorry, I should've clarified that! You can just change the English wording and our translation tools with take care of other languages before the next version is released.

Agoni-0 commented 1 month ago

Sorry, I should've clarified that! You can just change the English wording and our translation tools with take care of other languages before the next version is released.

Sorry, I'm not familiar with the app's translation tools. Do you mean to modify all strings.xml files like strings.xml (az) ?

nbradbury commented 1 month ago

Do you mean to modify all strings.xml files like strings.xml (az) ?

No, just the single English strings file shown as the first strings.xml file below the strings folder.

Screenshot 2024-10-23 at 10 18 22 AM

Agoni-0 commented 1 month ago

May I ask you a question? May I ask how to test the code that are changed in the Jetpack section?

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

nbradbury commented 1 month ago

May I ask you a question? May I ask how to test the code that are changed in the Jetpack section?

Just change the build variant.

Screenshot 2024-10-23 at 2 43 59 PM