[FEATURE] Better editor tabs
In the telegram group there was a message mentioning editor tab names spanning multiple lines. This pull request aims to solve this and it also adds icons to those tabs depending on file types.
This PR is for now a draft, because I have some things to discuss.
- Here is how tabs look with and without an icon. Even though
tabMaxWidthis set to 0, therefore theTextViewshould just become bigger, for some reason with an icon enabled, the text is truncated. I assume that this depends on the inner implementation ofTabLayout.TabView. Most of the methods there are private, therefore we can not really customize the implementation. I will try inserting a custom viewe for each tab, but am unsure if it will help. On the other hand, do we really need full size names? In most PC IDEs you will have the same picture of names on the tabs being truncated with...and after all there aren't that many cases of file names being too long to fit.
🖼️ Screenshots of new tabs with and without icons
- I changed the implementation of the
FileExtensionenum a bit. It now has more entries with.extensionbeing an empty string. However, it is only used in two places now and.extensionis never really used. Please, tell me if I have to separate this API into a separate function likeFileUtils.getIcon(File file).
Currently working with setting a custom layout resource for all tabs. Seems like this approach is only partially supported. For example, text color should be changed separately, according to this comment. This will make a solution rather hacky. Additionally, as I said, too long names on tabs look somewhat bad. I think, we should leave it with tabMaxWidth="0dp" so it looks as in first screenshot. Additionally we might add a settings option to enable or disable icons on tabs, though this seems somewhat unnecessary.
Sorry for the late reply.
On the other hand, do we really need full size names? In most PC IDEs you will have the same picture of names on the tabs being truncated with ... and after all there aren't that many cases of file names being too long to fit.
I don't think we need to show the full file names. The current ellipsize behavior seems fine to me.
I changed the implementation of the FileExtension enum a bit. It now has more entries with .extension being an empty string. However, it is only used in two places now and .extension is never really used. Please, tell me if I have to separate this API into a separate function like FileUtils.getIcon(File file).
You can let it be as it is.
I think, we should leave it with tabMaxWidth="0dp" so it looks as in first screenshot.
Yes, the default behavior is okay.
Additionally we might add a settings option to enable or disable icons on tabs, though this seems somewhat unnecessary.
We don't need a preference option for that.
This last commit finalizes the pull request with a little bit of code cleanup. The PR is ready to merge, I think.
I think my next pull request will reimplement the FileExtension class to not include the extensions, because right now it is only used to acquire icons for specific file types and nowhere in the codebase it is being used to check the extension of a file. Moreover, some enum entries do not provide file extensions, and we check for images with ImageUils and not by file extension. A class like FileIcon with static methods forFile and forName returning drawable ids would be a more appropriate implementation in my opinion.
Merged (cee7d6a02471c5f2366071a48dcf9dce4e6fc2f8).