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

Compress dictionaries and allow users to add more #569

Merged

Conversation

Helium314
Copy link
Contributor

@Helium314 Helium314 commented Mar 18, 2022

Compressed files can't be read directly by the native library, so the dictionaries were uncompressed so far.
This PR changes the behavior a bit, so the content of an accessed dictionary is copied to internal files directory when the dictionary is loaded for the first time.
Loading from internal files directory is current behavior anyway, so on further loads the dictionary is loaded from there.

Locale matching is done like previously, so always the same locale should be selected.

Sort of fixes #47, though even the compressed size is now 30 MB and thus bigger than the 24 MB in the initial complaint.

Anyway, further size reduction should be possible by removing some dictionaries and allowing to load dictionaries from files, which would simply copy the content to internal files directory to the correct locale. But the user would have to download dictionaries manually.

[Edit: change title and link issues]
fixes #355
fixes #219

compressed files can't be read directly, so they are copied to files directorey before accessing
this still saves space, except if a user decides to use most of the available dictionaries
@Helium314
Copy link
Contributor Author

allowing to load dictionaries from files, which would simply copy the content to internal files directory to the correct locale

I just tried this: it was quite simple to implement and doesn't require any new permissions (using Intent.ACTION_OPEN_DOCUMENT and storage access framework)
I'll upgrade the PR once the code is a bit cleaner.

Rough sketch of UI:
Add some "add dictionary" preference, opens a dialog when clicked.
Dialog tells user that they can choose a dictionary file, and provides a link to where they can be downloaded (maybe some folder in the repo?).
When a file is picked there is another dialog:

  • informs that dictionary was added for locale
  • maybe: asks whether existing dicionary should be overwritten (only if new version is older?)
  • informs about any errors

@MajeurAndroid / @dslul is that approach ok?

@dslul
Copy link
Member

dslul commented Mar 19, 2022

Looks good to me, thanks a lot for the effort!

@Helium314
Copy link
Contributor Author

Great!
So this works now.

Three things that may or may not need a change:

  • Currently there is no way of deleting dictionaries added by the user, e.g. because a dictionary turns out to be worse than default. The only way of going back to default is by downloading the default dictionary.
  • Better locale match is always preferred. If a user with pt_br adds a dictionary for pt, the new dictionary would never be used as pt_br already exists. I don't know what could be done here, but at the same time I think it is not really likely to actually happen. Thus I'm inclined to leave this as it is.
  • I point the users to https://github.com/openboard-team/openboard/ for downloading dictionaries, which is currently wrong / not useful. But I guess this will improve quickly as there seem to be several dictionaries ready (looking at other PRs).

@Helium314 Helium314 changed the title Compress dictionaries Compress dictionaries and allow users to add more Mar 19, 2022
@Helium314
Copy link
Contributor Author

I'm going to implement a proper preferences screen for showing, adding, updating and deleting dictionaries.
Interstingly my worst problem is getting a proper icon... help on finding something is highly appreciated!

@MajeurAndroid
Copy link
Member

This looks really good, I wanted to do this for a long time, nice one.
We'll do another branch for this too, as it's a big and I think really long-awaited feature. So we can make sure it's OK before merging it.
For the icons, don't bother, you can use dummy existing ones, I'll import new ones later, I have some toolings to support this old icon format.

@MajeurAndroid MajeurAndroid changed the base branch from master to feature-external-dicts March 21, 2022 12:04
@MajeurAndroid MajeurAndroid merged commit 8d92f1a into openboard-team:feature-external-dicts Mar 21, 2022
@Helium314
Copy link
Contributor Author

@MajeurAndroid is there anything I can do to get this implemented?

@Helium314
Copy link
Contributor Author

@MajeurAndroid @dslul I don't want to be annoying, but considering the number of open issues / PRs regarding dictionaries, adding dictionaries from a file has the potential to help a lot of people.

What needs to be done to get this feature (and fix #578) into the main branch?

Helium314 added a commit to Helium314/HeliBoard that referenced this pull request Jun 26, 2023
openboard-team/openboard#569
openboard-team/openboard#578
modified so dictionaries use the correct type instead of always main
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.

OpenBoard package size feature request: add dictionaries from the application Reduce size of package
3 participants