ManeraKai / simplytranslate_mobile

Privacy friendly frontend to Google Translate
https://manerakai.github.io/simplytranslate_mobile/
GNU General Public License v3.0
173 stars 15 forks source link

Limitation of number text characters #91

Closed Valdnet closed 3 years ago

Valdnet commented 3 years ago

You should set a limit for the number of text characters. If you enter more than 100000, the character counter icon will spread. Restriction on entering and pasting text 😉.

obraz

I suggest limiting to 9999 characters.

Valdnet commented 3 years ago

The function does not meet all the requirements. Currently, it only limits the display of the character count to 9999.

obraz

obraz

You should add:

  1. If pasting is to exceed the character limit, it only pastes to = 9999 truncates the rest.
  2. The counter icon turns red and blocks the "Paste" icon.
  1. If writing exceeds the character limit, it blocks writing.
  2. The counter icon turns red and blocks the "Paste" icon.
ManeraKai commented 3 years ago

Why shouldn't I just limit characters to 5000? The app can handle more than 9999. Limiting it just because of a small number that can have a get around fix (talking about 9999) is not a good idea in my opinion.

Valdnet commented 3 years ago

Why shouldn't I just limit characters to 5000?

I completely forgot. I'm sorry my mistake.

Why is it not limited to >5000 😁?

Issues: #63 #80.

ManeraKai commented 3 years ago

To give the user the ability to cut, but it will really be cut anyways. I'll just limited it to 5000. I'll keep the character limit indicator though.

Valdnet commented 3 years ago

I'll keep the character limit indicator though.

Exactly. It can come in handy when translating when switching languages 😉. Maybe there is a language that can translate from 5000 characters to more than 9999 characters 😁.

Valdnet commented 3 years ago

blocks the "Paste" icon.

The condition in point 2 is not met. The "Paste" icon is still active. Remember that after removing at least one text character the "Paste" icon should change to the active one.

obraz

Valdnet commented 3 years ago

I suggest that the user can paste or write 5001 characters, then the user will be informed that the counter is exceeded. That will be better.

ManeraKai commented 3 years ago

Prefer to just display the 5000 as red and maybe shake it in the future. The user will notice by then why he can't type more.

Valdnet commented 3 years ago

Prefer to just display the 5000 as red

But the red one will inform about exceeding the counter. It may mislead the user who chooses not to send the translation.

I still suggest 5001 characters 😉.

Valdnet commented 3 years ago

When switching languages, when the back translation exceeds 5000 characters, the counter is not red and the "Paste" icon is not grayed out.

obraz

ManeraKai commented 3 years ago

As the commit title said. Did all that. Maybe you'll have some notes on the switch lang function: https://github.com/ManeraKai/simplytranslate-flutter-client/actions/runs/1270012417 Improved on the cancel button too.

Valdnet commented 3 years ago

After testing, I find you were right. The text input limit should be up to 5000 characters. The user is already signaled with the inactive "Paste" icon that he will exceed the counter.

Additionally, I noticed that the "Paste" icon is active again on the empty clipboard.

ManeraKai commented 3 years ago

The text input limit should be up to 5000 characters.

So changing it back?

Additionally, I noticed that the "Paste" icon is active again on the empty clipboard.

It will be active all the time. I wasn't able to solve the issue. I can't leave it to it-self's mood active or not active for a release version.

Valdnet commented 3 years ago

So changing it back?

Yes. Sorry for the confusion, but it will be better for the user of the program 😉.

If you exceed the counter while reverse translating and editing the text by deleting characters, the program will drop to 5001 characters at once, not one at a time. This is what the counter shows. Why?

>5006

obraz

5006 - 1 = 5005 (indicates 5001)

obraz

ManeraKai commented 3 years ago

If you exceed the counter while reverse translating and editing the text by deleting characters, the program will drop to 5001 characters at once, not one at a time. This is what the counter shows. Why?

The TextField doesn't allow the input to exceed 5000. However, you can get around that by editing it's controller. i.e googleTranslationInputController.text = translatedText. This way, you will have more than 5000 chars in the TextField without it noticing. However, when you start editing the text. It will wake up and check if it's really 5000. It finds out that it got betrayed, cuts the end of the input till its 5000 chars again, and sleeps again.

ManeraKai commented 3 years ago

This is a bug. The user should be able to type more than 5000 chars, bu shouldn't be able to submit. However, I don't know what should happen if he pressed the switch lang btn. The switch lang btn will be forced to cut the text and submit it. That will mislead the user, I think if the switch lang btn encountered this, it should stop and alert the user by the counter indicator, so he can edit the text and submit it manually.

What do you think?

Valdnet commented 3 years ago

The user should be able to type more than 5000 chars, bu shouldn't be able to submit.

I have looked at it all again and I agree with you 👍. The user should be able to enter more than 5000 characters and possibly edit and adjust the sentences.

I think we are resigning from the 5000 character lock. But what about an overflow of 99999 characters. Maybe make a blockade here? Just like I thought at the beginning.

What do you think? Or maybe some other idea?

ManeraKai commented 3 years ago

But what about an overflow of 99999 characters.

The main problem with the 10000 is that the counter indicator doesn't fit. I can get around that though by resizing the text to be smaller and smaller, but there should be a limit to that. Maybe above 99999 isn't allowed?

Valdnet commented 3 years ago

Maybe above 99999 isn't allowed?

I think so too 👍.

ManeraKai commented 3 years ago

Did that: https://github.com/ManeraKai/simplytranslate-flutter-client/actions/runs/1270606001 The paste button will be inactive when the counter reaches 99999.

Valdnet commented 3 years ago

The paste button will be inactive when the counter reaches 99999.

And writing text is also blocked after >99999?

ManeraKai commented 3 years ago

one minute one minute.

ManeraKai commented 3 years ago

The textfield counts differently than my custom counter: image The left smal grey counter is the TextField's one. Mine is on the right.

Valdnet commented 3 years ago

The textfield counts differently than my custom counter:

This is interesting. Why is it like that?

ManeraKai commented 3 years ago

I think it's because of spaces and new lines. But I don't know which one google uses.

ManeraKai commented 3 years ago

Fixed.

Valdnet commented 3 years ago

Successful test 👍.

I close the issue.

Valdnet commented 3 years ago

@ManeraKai I have never seen this message. Is it working properly? Or maybe it is unnecessary?

https://github.com/ManeraKai/simplytranslate-flutter-client/blob/5b370ec74cd999fdaeb08f090b056cf0bfda46cb/lang/main_en.arb#L126 https://github.com/ManeraKai/simplytranslate-flutter-client/blob/5b370ec74cd999fdaeb08f090b056cf0bfda46cb/lib/google/widgets/lang_selector/switch_lang.dart#L55

ManeraKai commented 3 years ago

It's when the user switches a translated text that is under 5000, but the translated result is over 5000. So, now we've translated and flipped, but we can't translate the last time. So we inform the user about that, so he can edit the text manually and get a result without us cutting the text without him knowing and misleading him about the translation.

Valdnet commented 3 years ago

Well. I checked it works 😉.

ManeraKai commented 3 years ago

I sometimes alerts me but with the text below 5000. I'll check it later as it's a rare thing.

Valdnet commented 3 years ago

I checked. If the message appears after >5000 characters, then the next replacement of the translation after decreasing the characters also appears even if the characters are =5000 or <5000.

ManeraKai commented 3 years ago

This was the issue: https://github.com/ManeraKai/simplytranslate-flutter-client/blob/main/lib/google/widgets/lang_selector/switch_lang.dart#L60

ManeraKai commented 3 years ago

Fixed. I think this issue should now be closed @Valdnet?

Valdnet commented 3 years ago

I've seen this before, and so I thought it was a one-zero mistake. Great you found a bug 👍.

I close the issue. If the test turns negative, the best I can do is open it again.