Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proof of concept] Added autosizing of text and updated the project #30

Closed
wants to merge 1 commit into from
Closed

Conversation

LemmusLemmus
Copy link
Contributor

@LemmusLemmus LemmusLemmus commented Jul 30, 2021

I've implemented a form of text autosizing (#29) and customizable text padding, as well as updated the target sdk to api 28 and necessarily migrated the project to AndroidX. I also updated the min sdk to api 23, which was necessary in order to check if the screen was round easily (there are of course other methods to do so which do not necessitate raising the min sdk, but none as straightforward). I might give updating the project even further a try, assuming that I do not hit a brick wall in the process ;/

The method is imperfect and as such this is merely a proof of concept. It should however work well in most cases.

I used a dummy TextView to get the correct text size, as Autosizing does not work well inside a ScrollView. Even though this isn't an ideal solution, it is not the main reason for the messy code, but rather the fact that Autosizing prioritizes increasing font size over not splitting words in the middle, something which can result in very unsightly text. The code to fix this issue is also imperfect, among other things I had to change the word break strategy.

Some identified problems:

  • Occurrences of the character " " at the end of the text will shift the text leftwards, which can sometimes cause the text to be cut off for some reason. A simple fix would be to simply remove any whitespace characters at the end of the text, since they serve no use anyways and only takes up the limited screen space. EDIT: fixed.
  • One can currently momentarily see the previous font size in the new text, for better or worse. This can however be fixed relatively easily, but I don't know what the best approach to do so would be.

Some things that needs to be done:

  • Translations
  • It should perhaps be possible to select a negative value in the extra padding number picker. This does however necessitate altering the number picker code, which I haven't been bothered with.
  • Improve the code and remove redundant lines of code. There might even be some redundant files in this pull-request as I merely dragged over the project folder after removing the unnecessary files that I could spot.
  • Test with an actual rectangular screen. The code should hopefully handle rectangular screens, but I haven't actually tested it with one. In this proof of concept I have removed the default 25dp top and bottom "padding" of the rectangular layout, this does however mean that the buttons may cover up valuable information. I could re-implement the padding in one form or another, but I wonder if that is the best option here. Maybe the slide buttons should be redesigned as to take up as little space as possible (e.g. a simple coloured bar (or a curved bar for round screens), with no information whatsoever until the user interacts with it)?

As a side note, is there a particular reason as to why the rect. wear activity TextView has clickable and focusable set to true, whereas the round wear activity does not?

@LemmusLemmus
Copy link
Contributor Author

LemmusLemmus commented Aug 28, 2021

Notable new additions (still very much a mere proof of concept):

  • Text cleanup (removal of unnecessary whitespaces in particular)
  • One can now scroll between the back and front cards after showing the answer (double pressing works as usual)
  • New smaller buttons. I'm afraid I got very lazy here and have not adapted them to different screen sizes. The idea is to generate vector art of buttons beforehand, taking into account the shape and size of the screen as to make the buttons flush with the screen borders.

Screenshots (using a round screen):
Front of card:
screen
Back of card:
screen(1)
Scrolling between the card sides:
screen(2)
Using (sliding) the rounded button:
screen(3)

Comments with //P in the code means that the code is very much personal and not (yet) adapted for general use.

Some additional identified problems:

  • The "play sound" buttons are sometimes invisible. The autosizing of text does not take this button into consideration. It might perhaps be wise to display the buttons in a separate row on the top and/or bottom of the screen (similar to how it is done in Ankidroid and Anki desktop).
  • The rotating bezel ceased to function properly in the app around the time of the migration to androidx, if I'm not mistaken. Is was able to fix the problem in the review window by setting the focus to the scrollview, but I've yet to make it work again in the deck list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant